Index: Core/Components/src/Core.Components.Charting.Forms/IChartControl.cs
===================================================================
diff -u -rf04895089d34bddb618db8c7001c574428be10c6 -r4dbfc20ef0200e34db43efeb8899d72e4046cc5b
--- Core/Components/src/Core.Components.Charting.Forms/IChartControl.cs (.../IChartControl.cs) (revision f04895089d34bddb618db8c7001c574428be10c6)
+++ Core/Components/src/Core.Components.Charting.Forms/IChartControl.cs (.../IChartControl.cs) (revision 4dbfc20ef0200e34db43efeb8899d72e4046cc5b)
@@ -41,7 +41,7 @@
///
/// Gets or sets the data to show in the .
///
- ChartDataCollection Data { get; }
+ ChartDataCollection Data { get; set; }
///
/// Gets or sets the title of the chart.
@@ -72,10 +72,5 @@
/// Zooms to a level so that everything is in view.
///
void ZoomToAll();
-
- ///
- /// Sets the data of the chart to null.
- ///
- void ResetChartData();
}
}
\ No newline at end of file
Index: Core/Components/src/Core.Components.Charting/Core.Components.Charting.csproj
===================================================================
diff -u -r1795be9025cb0e054dca86a5275203966c0a9b2a -r4dbfc20ef0200e34db43efeb8899d72e4046cc5b
--- Core/Components/src/Core.Components.Charting/Core.Components.Charting.csproj (.../Core.Components.Charting.csproj) (revision 1795be9025cb0e054dca86a5275203966c0a9b2a)
+++ Core/Components/src/Core.Components.Charting/Core.Components.Charting.csproj (.../Core.Components.Charting.csproj) (revision 4dbfc20ef0200e34db43efeb8899d72e4046cc5b)
@@ -44,6 +44,7 @@
+
Index: Core/Components/src/Core.Components.Charting/Data/ChartMultipleAreaData.cs
===================================================================
diff -u -r38ee40c1f98ff4b1921d4de64fd032c8fbcadf92 -r4dbfc20ef0200e34db43efeb8899d72e4046cc5b
--- Core/Components/src/Core.Components.Charting/Data/ChartMultipleAreaData.cs (.../ChartMultipleAreaData.cs) (revision 38ee40c1f98ff4b1921d4de64fd032c8fbcadf92)
+++ Core/Components/src/Core.Components.Charting/Data/ChartMultipleAreaData.cs (.../ChartMultipleAreaData.cs) (revision 4dbfc20ef0200e34db43efeb8899d72e4046cc5b)
@@ -30,7 +30,7 @@
///
/// This class represents data in 2D space which forms multiple closed areas.
///
- public class ChartMultipleAreaData : ChartData
+ public class ChartMultipleAreaData : ItemBasedChartData
{
private IEnumerable areas;
Index: Core/Components/src/Core.Components.Charting/Data/ItemBasedChartData.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.Charting/Data/ItemBasedChartData.cs (revision 0)
+++ Core/Components/src/Core.Components.Charting/Data/ItemBasedChartData.cs (revision 4dbfc20ef0200e34db43efeb8899d72e4046cc5b)
@@ -0,0 +1,39 @@
+// 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;
+
+namespace Core.Components.Charting.Data
+{
+ ///
+ /// Base class for that contains items like points or areas.
+ ///
+ public abstract class ItemBasedChartData : ChartData
+ {
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The name of the .
+ /// Thrown when is
+ /// null or only whitespace.
+ protected ItemBasedChartData(string name) : base(name) {}
+ }
+}
\ No newline at end of file
Index: Core/Components/src/Core.Components.Charting/Data/PointBasedChartData.cs
===================================================================
diff -u -r38ee40c1f98ff4b1921d4de64fd032c8fbcadf92 -r4dbfc20ef0200e34db43efeb8899d72e4046cc5b
--- Core/Components/src/Core.Components.Charting/Data/PointBasedChartData.cs (.../PointBasedChartData.cs) (revision 38ee40c1f98ff4b1921d4de64fd032c8fbcadf92)
+++ Core/Components/src/Core.Components.Charting/Data/PointBasedChartData.cs (.../PointBasedChartData.cs) (revision 4dbfc20ef0200e34db43efeb8899d72e4046cc5b)
@@ -25,9 +25,9 @@
namespace Core.Components.Charting.Data
{
///
- /// Base class for which is based on an array of points in 2D space.
+ /// Base class for that is based on an array of points in 2D space.
///
- public abstract class PointBasedChartData : ChartData
+ public abstract class PointBasedChartData : ItemBasedChartData
{
private Point2D[] points;
Index: Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs
===================================================================
diff -u -r2cafb330e0b90d1103bc9329eafbcba24836787f -r4dbfc20ef0200e34db43efeb8899d72e4046cc5b
--- Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs (.../MapControl.cs) (revision 2cafb330e0b90d1103bc9329eafbcba24836787f)
+++ Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs (.../MapControl.cs) (revision 4dbfc20ef0200e34db43efeb8899d72e4046cc5b)
@@ -227,7 +227,7 @@
drawnMapDataLookup = drawnMapDataList.ToDictionary(dmd => dmd.FeatureBasedMapData, dmd => dmd);
- MoveMapDataOnCollectionChange(mapDataThatShouldBeDrawn, drawnMapDataLookup);
+ ReorderMapDataOnCollectionChange(mapDataThatShouldBeDrawn, drawnMapDataLookup);
}
private void DrawMissingMapDataOnCollectionChange(IEnumerable mapDataThatShouldBeDrawn,
@@ -248,8 +248,8 @@
}
}
- private void MoveMapDataOnCollectionChange(IList mapDataThatShouldBeDrawn,
- IDictionary drawnMapDataLookup)
+ private void ReorderMapDataOnCollectionChange(IList mapDataThatShouldBeDrawn,
+ IDictionary drawnMapDataLookup)
{
for (var i = 0; i < mapDataThatShouldBeDrawn.Count; i++)
{
@@ -287,21 +287,21 @@
private static IEnumerable GetFeatureBasedMapDataRecursively(MapDataCollection mapDataCollection)
{
- var featureBaseMapDataList = new List();
+ var featureBasedMapDataList = new List();
foreach (MapData mapData in mapDataCollection.Collection)
{
var nestedMapDataCollection = mapData as MapDataCollection;
if (nestedMapDataCollection != null)
{
- featureBaseMapDataList.AddRange(GetFeatureBasedMapDataRecursively(nestedMapDataCollection));
+ featureBasedMapDataList.AddRange(GetFeatureBasedMapDataRecursively(nestedMapDataCollection));
continue;
}
- featureBaseMapDataList.Add((FeatureBasedMapData) mapData);
+ featureBasedMapDataList.Add((FeatureBasedMapData) mapData);
}
- return featureBaseMapDataList;
+ return featureBasedMapDataList;
}
private void MapFunctionActivateFunction(object sender, EventArgs e)
Index: Core/Components/src/Core.Components.DotSpatial/Converter/FeatureBasedMapDataConverter.cs
===================================================================
diff -u -r7ab976b1a6799058565681fd87400d48fc72f140 -r4dbfc20ef0200e34db43efeb8899d72e4046cc5b
--- Core/Components/src/Core.Components.DotSpatial/Converter/FeatureBasedMapDataConverter.cs (.../FeatureBasedMapDataConverter.cs) (revision 7ab976b1a6799058565681fd87400d48fc72f140)
+++ Core/Components/src/Core.Components.DotSpatial/Converter/FeatureBasedMapDataConverter.cs (.../FeatureBasedMapDataConverter.cs) (revision 4dbfc20ef0200e34db43efeb8899d72e4046cc5b)
@@ -121,7 +121,7 @@
{
if (data == null)
{
- throw new ArgumentNullException("data", @"Null data cannot be converted into a feature layer data.");
+ throw new ArgumentNullException("data", @"Null data cannot be converted into feature layer data.");
}
if (layer == null)
Index: Core/Components/src/Core.Components.OxyPlot.Forms/ChartControl.cs
===================================================================
diff -u -r640df7c0609a81e19cc3661323ee461d801049b0 -r4dbfc20ef0200e34db43efeb8899d72e4046cc5b
--- Core/Components/src/Core.Components.OxyPlot.Forms/ChartControl.cs (.../ChartControl.cs) (revision 640df7c0609a81e19cc3661323ee461d801049b0)
+++ Core/Components/src/Core.Components.OxyPlot.Forms/ChartControl.cs (.../ChartControl.cs) (revision 4dbfc20ef0200e34db43efeb8899d72e4046cc5b)
@@ -19,26 +19,29 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
-using System.ComponentModel;
+using System.Collections.Generic;
using System.Drawing;
+using System.Linq;
using System.Windows.Forms;
using Core.Common.Base;
using Core.Components.Charting.Data;
using Core.Components.Charting.Forms;
-using Core.Components.OxyPlot.Converter;
-using OxyPlot.WindowsForms;
+using Core.Components.OxyPlot.DataSeries;
+using OxyPlot.Series;
namespace Core.Components.OxyPlot.Forms
{
///
/// This class describes a plot view with configured representation of axes.
///
- public sealed class ChartControl : Control, IObserver, IChartControl
+ public sealed class ChartControl : Control, IChartControl
{
- private readonly ChartSeriesFactory seriesFactory = new ChartSeriesFactory();
+ private readonly RecursiveObserver chartDataCollectionObserver;
+ private readonly IList drawnChartDataList = new List();
- private LinearPlotView view;
- private DynamicPlotController controller;
+ private LinearPlotView plotView;
+ private DynamicPlotController plotController;
+ private ChartDataCollection data;
///
/// Creates a new instance of .
@@ -48,125 +51,264 @@
InitializePlotView();
MinimumSize = new Size(100, 100);
- Data = new ChartDataCollection("Root");
- Data.Attach(this);
-
- DrawSeries();
+ chartDataCollectionObserver = new RecursiveObserver(HandleChartDataCollectionChange, cdc => cdc.Collection);
}
- ///
- /// Initialize the for the .
- ///
- private void InitializePlotView()
+ public ChartDataCollection Data
{
- view = new LinearPlotView
+ get
{
- BackColor = Color.White
- };
+ return data;
+ }
+ set
+ {
+ if (data != null)
+ {
+ ClearChartData();
+ }
- controller = new DynamicPlotController();
- view.Controller = controller;
- Controls.Add(view);
- }
+ data = value;
- ///
- /// Draws series based on the currently set .
- ///
- private void DrawSeries()
- {
- view.Model.Series.Clear();
- if (Data != null)
- {
- foreach (var series in seriesFactory.Create(Data))
+ chartDataCollectionObserver.Observable = data;
+
+ if (data != null)
{
- view.Model.Series.Add(series);
+ DrawInitialChartData();
}
}
- view.InvalidatePlot(true);
}
- #region IChart
-
- public bool IsPanningEnabled
+ public string ChartTitle
{
get
{
- return controller.IsPanningEnabled;
+ return plotView.ModelTitle;
}
- }
-
- public bool IsRectangleZoomingEnabled
- {
- get
+ set
{
- return controller.IsRectangleZoomingEnabled;
+ plotView.ModelTitle = value;
}
}
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public ChartDataCollection Data { get; private set; }
-
- public string ChartTitle
+ public string BottomAxisTitle
{
get
{
- return view.ModelTitle;
+ return plotView.BottomAxisTitle;
}
set
{
- view.ModelTitle = value;
+ plotView.BottomAxisTitle = value;
}
}
- public string BottomAxisTitle
+ public string LeftAxisTitle
{
get
{
- return view.BottomAxisTitle;
+ return plotView.LeftAxisTitle;
}
set
{
- view.BottomAxisTitle = value;
+ plotView.LeftAxisTitle = value;
}
}
- public string LeftAxisTitle
+ public bool IsPanningEnabled
{
get
{
- return view.LeftAxisTitle;
+ return plotController.IsPanningEnabled;
}
- set
+ }
+
+ public bool IsRectangleZoomingEnabled
+ {
+ get
{
- view.LeftAxisTitle = value;
+ return plotController.IsRectangleZoomingEnabled;
}
}
public void TogglePanning()
{
- controller.TogglePanning();
+ plotController.TogglePanning();
}
public void ToggleRectangleZooming()
{
- controller.ToggleRectangleZooming();
+ plotController.ToggleRectangleZooming();
}
public void ZoomToAll()
{
- view.ZoomToAll();
+ plotView.ZoomToAll();
}
- public void UpdateObserver()
+ protected override void Dispose(bool disposing)
{
- DrawSeries();
+ plotView.Dispose();
+ chartDataCollectionObserver.Dispose();
+
+ base.Dispose(disposing);
}
- public void ResetChartData()
+ private void InitializePlotView()
{
- Data = null;
+ plotView = new LinearPlotView
+ {
+ BackColor = Color.White,
+ Model =
+ {
+ IsLegendVisible = false
+ }
+ };
+
+ plotController = new DynamicPlotController();
+ plotView.Controller = plotController;
+
+ Controls.Add(plotView);
}
- #endregion
+ private static IEnumerable GetItemBasedChartDataRecursively(ChartDataCollection chartDataCollection)
+ {
+ var itemBasedChartDataList = new List();
+
+ foreach (ChartData chartData in chartDataCollection.Collection)
+ {
+ var nestedChartDataCollection = chartData as ChartDataCollection;
+ if (nestedChartDataCollection != null)
+ {
+ itemBasedChartDataList.AddRange(GetItemBasedChartDataRecursively(nestedChartDataCollection));
+ continue;
+ }
+
+ itemBasedChartDataList.Add((ItemBasedChartData) chartData);
+ }
+
+ return itemBasedChartDataList;
+ }
+
+ private void HandleChartDataCollectionChange()
+ {
+ var chartDataThatShouldBeDrawn = GetItemBasedChartDataRecursively(Data).ToList();
+ var drawnChartDataLookup = drawnChartDataList.ToDictionary(dcd => dcd.ItemBasedChartData, dcd => dcd);
+
+ DrawMissingChartDataOnCollectionChange(chartDataThatShouldBeDrawn, drawnChartDataLookup);
+ RemoveRedundantChartDataOnCollectionChange(chartDataThatShouldBeDrawn, drawnChartDataLookup);
+
+ drawnChartDataLookup = drawnChartDataList.ToDictionary(dcd => dcd.ItemBasedChartData, dcd => dcd);
+
+ ReorderChartDataOnCollectionChange(chartDataThatShouldBeDrawn, drawnChartDataLookup);
+
+ plotView.InvalidatePlot(true);
+ }
+
+ private void DrawMissingChartDataOnCollectionChange(IEnumerable chartDataThatShouldBeDrawn,
+ IDictionary drawnChartDataLookup)
+ {
+ foreach (var chartDataToDraw in chartDataThatShouldBeDrawn)
+ {
+ if (!drawnChartDataLookup.ContainsKey(chartDataToDraw))
+ {
+ DrawChartData(chartDataToDraw);
+ }
+ }
+ }
+
+ private void RemoveRedundantChartDataOnCollectionChange(IEnumerable chartDataThatShouldBeDrawn,
+ IDictionary drawnChartDataLookup)
+ {
+ foreach (var itemBasedChartData in drawnChartDataLookup.Keys.Except(chartDataThatShouldBeDrawn))
+ {
+ RemoveChartData(drawnChartDataLookup[itemBasedChartData]);
+ }
+ }
+
+ private void ReorderChartDataOnCollectionChange(IEnumerable chartDataThatShouldBeDrawn,
+ IDictionary drawnChartDataLookup)
+ {
+ plotView.Model.Series.Clear();
+
+ foreach (ItemBasedChartData itemBasedChartData in chartDataThatShouldBeDrawn)
+ {
+ plotView.Model.Series.Add((Series) drawnChartDataLookup[itemBasedChartData].ItemBasedChartDataSeries);
+ }
+ }
+
+ private void RemoveChartData(DrawnChartData drawnChartDataToRemove)
+ {
+ drawnChartDataToRemove.Observer.Dispose();
+ drawnChartDataList.Remove(drawnChartDataToRemove);
+
+ plotView.Model.Series.Remove((Series) drawnChartDataToRemove.ItemBasedChartDataSeries);
+ }
+
+ private void DrawInitialChartData()
+ {
+ foreach (var itemBasedChartData in GetItemBasedChartDataRecursively(Data))
+ {
+ DrawChartData(itemBasedChartData);
+ }
+
+ plotView.InvalidatePlot(true);
+ }
+
+ private void DrawChartData(ItemBasedChartData itemBasedChartData)
+ {
+ var itemBasedChartDataSeries = ItemBasedChartDataSeriesFactory.Create(itemBasedChartData);
+
+ var drawnChartData = new DrawnChartData
+ {
+ ItemBasedChartData = itemBasedChartData,
+ ItemBasedChartDataSeries = itemBasedChartDataSeries
+ };
+
+ drawnChartData.Observer = new Observer(() =>
+ {
+ drawnChartData.ItemBasedChartDataSeries.Update();
+ plotView.InvalidatePlot(true);
+ })
+ {
+ Observable = itemBasedChartData
+ };
+
+ drawnChartDataList.Add(drawnChartData);
+
+ plotView.Model.Series.Add((Series) itemBasedChartDataSeries);
+ }
+
+ private void ClearChartData()
+ {
+ foreach (DrawnChartData drawnChartData in drawnChartDataList)
+ {
+ drawnChartData.Observer.Dispose();
+ }
+
+ drawnChartDataList.Clear();
+
+ plotView.Model.Series.Clear();
+ }
+
+ ///
+ /// Lookup class for administration related to drawn chart data series.
+ ///
+ private class DrawnChartData
+ {
+ ///
+ /// The item based chart data which the drawn is based upon.
+ ///
+ public ItemBasedChartData ItemBasedChartData { get; set; }
+
+ ///
+ /// The drawn chart data series.
+ ///
+ public IItemBasedChartDataSeries ItemBasedChartDataSeries { get; set; }
+
+ ///
+ /// The observer attached to and responsible for updating .
+ ///
+ public Observer Observer { get; set; }
+ }
}
}
\ No newline at end of file
Index: Core/Components/src/Core.Components.OxyPlot/Converter/ChartAreaDataConverter.cs
===================================================================
diff -u -red96d38a758365e4c0f117def83a2926c589c18a -r4dbfc20ef0200e34db43efeb8899d72e4046cc5b
--- Core/Components/src/Core.Components.OxyPlot/Converter/ChartAreaDataConverter.cs (.../ChartAreaDataConverter.cs) (revision ed96d38a758365e4c0f117def83a2926c589c18a)
+++ Core/Components/src/Core.Components.OxyPlot/Converter/ChartAreaDataConverter.cs (.../ChartAreaDataConverter.cs) (revision 4dbfc20ef0200e34db43efeb8899d72e4046cc5b)
@@ -19,49 +19,38 @@
// 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 OxyPlot;
using OxyPlot.Series;
namespace Core.Components.OxyPlot.Converter
{
///
- /// This class converts into .
+ /// The converter that converts data into data.
///
- public class ChartAreaDataConverter : ChartDataConverter
+ public class ChartAreaDataConverter : ItemBasedChartDataConverter
{
- protected override IList Convert(ChartAreaData data)
+ protected override void SetSeriesItems(ChartAreaData data, AreaSeries series)
{
- var series = new AreaSeries
- {
- IsVisible = data.IsVisible,
- Tag = data
- };
- foreach (var p in data.Points)
- {
- series.Points.Add(Point2DToDataPoint(p));
- }
+ series.Points.Clear();
+ series.Points2.Clear();
+
+ series.Points.AddRange(data.Points.Select(p => new DataPoint(p.X, p.Y)));
+
if (series.Points.Count > 0)
{
series.Points2.Add(series.Points[0]);
}
-
- CreateStyle(series, data.Style);
-
- return new List
- {
- series
- };
}
- private static void CreateStyle(AreaSeries series, ChartAreaStyle style)
+ protected override void SetSeriesStyle(ChartAreaData data, AreaSeries series)
{
- if (style != null)
+ if (data.Style != null)
{
- series.Fill = ChartDataHelper.Convert(style.FillColor);
- series.Color = ChartDataHelper.Convert(style.StrokeColor);
- series.StrokeThickness = style.Width;
+ series.Fill = ChartDataHelper.Convert(data.Style.FillColor);
+ series.Color = ChartDataHelper.Convert(data.Style.StrokeColor);
+ series.StrokeThickness = data.Style.Width;
}
}
}
Fisheye: Tag 4dbfc20ef0200e34db43efeb8899d72e4046cc5b refers to a dead (removed) revision in file `Core/Components/src/Core.Components.OxyPlot/Converter/ChartDataCollectionConverter.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 4dbfc20ef0200e34db43efeb8899d72e4046cc5b refers to a dead (removed) revision in file `Core/Components/src/Core.Components.OxyPlot/Converter/ChartDataConverter.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Core/Components/src/Core.Components.OxyPlot/Converter/ChartLineDataConverter.cs
===================================================================
diff -u -red96d38a758365e4c0f117def83a2926c589c18a -r4dbfc20ef0200e34db43efeb8899d72e4046cc5b
--- Core/Components/src/Core.Components.OxyPlot/Converter/ChartLineDataConverter.cs (.../ChartLineDataConverter.cs) (revision ed96d38a758365e4c0f117def83a2926c589c18a)
+++ Core/Components/src/Core.Components.OxyPlot/Converter/ChartLineDataConverter.cs (.../ChartLineDataConverter.cs) (revision 4dbfc20ef0200e34db43efeb8899d72e4046cc5b)
@@ -19,44 +19,30 @@
// 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 OxyPlot;
using OxyPlot.Series;
namespace Core.Components.OxyPlot.Converter
{
///
- /// This class converts into .
+ /// The converter that converts data into data.
///
- public class ChartLineDataConverter : ChartDataConverter
+ public class ChartLineDataConverter : ItemBasedChartDataConverter
{
- protected override IList Convert(ChartLineData data)
+ protected override void SetSeriesItems(ChartLineData data, LineSeries series)
{
- var series = new LineSeries
- {
- ItemsSource = data.Points.ToArray(),
- Mapping = Point2DToDataPoint,
- IsVisible = data.IsVisible,
- Tag = data
- };
-
- CreateStyle(series, data.Style);
-
- return new List
- {
- series
- };
+ series.ItemsSource = data.Points.Select(p => new DataPoint(p.X, p.Y));
}
- private static void CreateStyle(LineSeries series, ChartLineStyle style)
+ protected override void SetSeriesStyle(ChartLineData data, LineSeries series)
{
- if (style != null)
+ if (data.Style != null)
{
- series.Color = ChartDataHelper.Convert(style.Color);
- series.StrokeThickness = style.Width;
- series.LineStyle = ChartDataHelper.Convert(style.Style);
+ series.Color = ChartDataHelper.Convert(data.Style.Color);
+ series.StrokeThickness = data.Style.Width;
+ series.LineStyle = ChartDataHelper.Convert(data.Style.Style);
}
}
}
Index: Core/Components/src/Core.Components.OxyPlot/Converter/ChartMultipleAreaDataConverter.cs
===================================================================
diff -u -red96d38a758365e4c0f117def83a2926c589c18a -r4dbfc20ef0200e34db43efeb8899d72e4046cc5b
--- Core/Components/src/Core.Components.OxyPlot/Converter/ChartMultipleAreaDataConverter.cs (.../ChartMultipleAreaDataConverter.cs) (revision ed96d38a758365e4c0f117def83a2926c589c18a)
+++ Core/Components/src/Core.Components.OxyPlot/Converter/ChartMultipleAreaDataConverter.cs (.../ChartMultipleAreaDataConverter.cs) (revision 4dbfc20ef0200e34db43efeb8899d72e4046cc5b)
@@ -19,48 +19,35 @@
// 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;
+using OxyPlot;
namespace Core.Components.OxyPlot.Converter
{
///
- /// This class converts into .
+ /// The converter that converts data into data.
///
- public class ChartMultipleAreaDataConverter : ChartDataConverter
+ public class ChartMultipleAreaDataConverter : ItemBasedChartDataConverter
{
- protected override IList Convert(ChartMultipleAreaData data)
+ protected override void SetSeriesItems(ChartMultipleAreaData data, MultipleAreaSeries series)
{
- var series = new MultipleAreaSeries
- {
- IsVisible = data.IsVisible,
- Tag = data
- };
+ series.Areas.Clear();
foreach (var area in data.Areas)
{
- series.Areas.Add(area.Select(Point2DToDataPoint).ToArray());
+ series.Areas.Add(area.Select(p => new DataPoint(p.X, p.Y)).ToArray());
}
-
- CreateStyle(series, data.Style);
-
- return new List
- {
- series
- };
}
- private static void CreateStyle(MultipleAreaSeries series, ChartAreaStyle style)
+ protected override void SetSeriesStyle(ChartMultipleAreaData data, MultipleAreaSeries series)
{
- if (style != null)
+ if (data.Style != null)
{
- series.Fill = ChartDataHelper.Convert(style.FillColor);
- series.Color = ChartDataHelper.Convert(style.StrokeColor);
- series.StrokeThickness = style.Width;
+ series.Fill = ChartDataHelper.Convert(data.Style.FillColor);
+ series.Color = ChartDataHelper.Convert(data.Style.StrokeColor);
+ series.StrokeThickness = data.Style.Width;
}
}
}
Index: Core/Components/src/Core.Components.OxyPlot/Converter/ChartPointDataConverter.cs
===================================================================
diff -u -red96d38a758365e4c0f117def83a2926c589c18a -r4dbfc20ef0200e34db43efeb8899d72e4046cc5b
--- Core/Components/src/Core.Components.OxyPlot/Converter/ChartPointDataConverter.cs (.../ChartPointDataConverter.cs) (revision ed96d38a758365e4c0f117def83a2926c589c18a)
+++ Core/Components/src/Core.Components.OxyPlot/Converter/ChartPointDataConverter.cs (.../ChartPointDataConverter.cs) (revision 4dbfc20ef0200e34db43efeb8899d72e4046cc5b)
@@ -19,49 +19,34 @@
// 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 OxyPlot;
using OxyPlot.Series;
namespace Core.Components.OxyPlot.Converter
{
///
- /// This class converts into with point styling.
+ /// The converter that converts data into data.
///
- public class ChartPointDataConverter : ChartDataConverter
+ public class ChartPointDataConverter : ItemBasedChartDataConverter
{
- protected override IList Convert(ChartPointData data)
+ protected override void SetSeriesItems(ChartPointData data, LineSeries series)
{
- var series = new LineSeries
- {
- ItemsSource = data.Points.ToArray(),
- IsVisible = data.IsVisible,
- Mapping = Point2DToDataPoint,
- LineStyle = LineStyle.None,
- MarkerType = MarkerType.Circle,
- Tag = data
- };
-
- CreateStyle(series, data.Style);
-
- return new List
- {
- series
- };
+ series.ItemsSource = data.Points.Select(p => new DataPoint(p.X, p.Y));
}
- private static void CreateStyle(LineSeries series, ChartPointStyle style)
+ protected override void SetSeriesStyle(ChartPointData data, LineSeries series)
{
- if (style != null)
+ series.LineStyle = LineStyle.None;
+
+ if (data.Style != null)
{
- series.MarkerFill = ChartDataHelper.Convert(style.Color);
- series.MarkerSize = style.Size;
- series.MarkerType = ChartDataHelper.Convert(style.Symbol);
- series.MarkerStroke = ChartDataHelper.Convert(style.StrokeColor);
- series.MarkerStrokeThickness = style.StrokeThickness;
+ series.MarkerFill = ChartDataHelper.Convert(data.Style.Color);
+ series.MarkerSize = data.Style.Size;
+ series.MarkerType = ChartDataHelper.Convert(data.Style.Symbol);
+ series.MarkerStroke = ChartDataHelper.Convert(data.Style.StrokeColor);
+ series.MarkerStrokeThickness = data.Style.StrokeThickness;
}
}
}
Fisheye: Tag 4dbfc20ef0200e34db43efeb8899d72e4046cc5b refers to a dead (removed) revision in file `Core/Components/src/Core.Components.OxyPlot/Converter/ChartSeriesFactory.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 4dbfc20ef0200e34db43efeb8899d72e4046cc5b refers to a dead (removed) revision in file `Core/Components/src/Core.Components.OxyPlot/Converter/IChartDataConverter.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Core/Components/src/Core.Components.OxyPlot/Converter/ItemBasedChartDataConverter.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.OxyPlot/Converter/ItemBasedChartDataConverter.cs (revision 0)
+++ Core/Components/src/Core.Components.OxyPlot/Converter/ItemBasedChartDataConverter.cs (revision 4dbfc20ef0200e34db43efeb8899d72e4046cc5b)
@@ -0,0 +1,94 @@
+// 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.Charting.Data;
+using OxyPlot.Series;
+
+namespace Core.Components.OxyPlot.Converter
+{
+ ///
+ /// Abstract base class for transforming data into data.
+ ///
+ /// The type of item based chart data to convert.
+ /// The type of series to set the converted data to.
+ public abstract class ItemBasedChartDataConverter
+ where TItemBasedChartData : ItemBasedChartData
+ where TSeries : Series
+ {
+ ///
+ /// Converts all item related data from to .
+ ///
+ /// The data to convert the item related data from.
+ /// The series to convert the item related data to.
+ /// Thrown when or is null.
+ public void ConvertSeriesItems(TItemBasedChartData data, TSeries series)
+ {
+ ValidateParameters(data, series);
+
+ SetSeriesItems(data, series);
+ }
+
+ ///
+ /// Converts all general properties (like and )
+ /// from to .
+ ///
+ /// The data to convert the general properties from.
+ /// The series to convert the general properties to.
+ /// Thrown when or is null.
+ public void ConvertSeriesProperties(TItemBasedChartData data, TSeries series)
+ {
+ ValidateParameters(data, series);
+
+ series.Title = data.Name;
+ series.IsVisible = data.IsVisible;
+
+ SetSeriesStyle(data, series);
+ }
+
+ ///
+ /// Sets items to based on .
+ ///
+ /// The data to create the items from.
+ /// The series to set the items to.
+ protected abstract void SetSeriesItems(TItemBasedChartData data, TSeries series);
+
+ ///
+ /// Set a style to based on .
+ ///
+ /// The data to create the style from.
+ /// The series to set the style to.
+ protected abstract void SetSeriesStyle(TItemBasedChartData data, TSeries series);
+
+ private static void ValidateParameters(TItemBasedChartData data, TSeries series)
+ {
+ if (data == null)
+ {
+ throw new ArgumentNullException("data", @"Null data cannot be converted into series data.");
+ }
+
+ if (series == null)
+ {
+ throw new ArgumentNullException("series", @"Null data cannot be used as conversion target.");
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Core/Components/src/Core.Components.OxyPlot/Core.Components.OxyPlot.csproj
===================================================================
diff -u -r1795be9025cb0e054dca86a5275203966c0a9b2a -r4dbfc20ef0200e34db43efeb8899d72e4046cc5b
--- Core/Components/src/Core.Components.OxyPlot/Core.Components.OxyPlot.csproj (.../Core.Components.OxyPlot.csproj) (revision 1795be9025cb0e054dca86a5275203966c0a9b2a)
+++ Core/Components/src/Core.Components.OxyPlot/Core.Components.OxyPlot.csproj (.../Core.Components.OxyPlot.csproj) (revision 4dbfc20ef0200e34db43efeb8899d72e4046cc5b)
@@ -50,17 +50,20 @@
Properties\GlobalAssembly.cs
-
-
+
+
+
+
-
-
+
+
+
@@ -80,6 +83,7 @@
False
+