PageRenderTime 46ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/Main/src/DynamicDataDisplay/DataSources/MultiDimensional/NonUniformDataSource2D.cs

#
C# | 113 lines | 88 code | 25 blank | 0 comment | 8 complexity | 84a97e0ee2b659ff58d3c0c1e63a8c5d MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. namespace Microsoft.Research.DynamicDataDisplay.DataSources.MultiDimensional
  7. {
  8. public class NonUniformDataSource2D<T> : INonUniformDataSource2D<T> where T : struct
  9. {
  10. public NonUniformDataSource2D(double[] xcoordinates, double[] ycoordinates, T[,] data)
  11. {
  12. if (xcoordinates == null)
  13. throw new ArgumentNullException("xcoordinates");
  14. if (ycoordinates == null)
  15. throw new ArgumentNullException("ycoordinates");
  16. if (data == null)
  17. throw new ArgumentNullException("data");
  18. this.xCoordinates = xcoordinates;
  19. this.yCoordinates = ycoordinates;
  20. BuildGrid();
  21. this.data = data;
  22. }
  23. private void BuildGrid()
  24. {
  25. grid = new Point[Width, Height];
  26. for (int iy = 0; iy < Height; iy++)
  27. {
  28. for (int ix = 0; ix < Width; ix++)
  29. {
  30. grid[ix, iy] = new Point(xCoordinates[ix], yCoordinates[iy]);
  31. }
  32. }
  33. }
  34. #region INonUniformDataSource2D<T> Members
  35. private double[] xCoordinates;
  36. public double[] XCoordinates
  37. {
  38. get { return xCoordinates; }
  39. }
  40. private double[] yCoordinates;
  41. public double[] YCoordinates
  42. {
  43. get { return yCoordinates; }
  44. }
  45. #endregion
  46. #region IDataSource2D<T> Members
  47. private T[,] data;
  48. public T[,] Data
  49. {
  50. get { return data; }
  51. }
  52. public IDataSource2D<T> GetSubset(int x0, int y0, int countX, int countY, int stepX, int stepY)
  53. {
  54. throw new NotImplementedException();
  55. }
  56. public void ApplyMappings(DependencyObject marker, int x, int y)
  57. {
  58. throw new NotImplementedException();
  59. }
  60. #endregion
  61. #region IGridSource2D Members
  62. private Point[,] grid;
  63. public Point[,] Grid
  64. {
  65. get { return grid; }
  66. }
  67. public int Width
  68. {
  69. get { return xCoordinates.Length; }
  70. }
  71. public int Height
  72. {
  73. get { return yCoordinates.Length; }
  74. }
  75. public event EventHandler Changed;
  76. #endregion
  77. #region IDataSource2D<T> Members
  78. public Microsoft.Research.DynamicDataDisplay.Charts.Range<T>? Range
  79. {
  80. get { throw new NotImplementedException(); }
  81. }
  82. public T? MissingValue
  83. {
  84. get { throw new NotImplementedException(); }
  85. }
  86. #endregion
  87. }
  88. }