using System; using System.Collections.Generic; using HeuristicLab.Visualization.LabelProvider; namespace HeuristicLab.Visualization { public delegate void YAxisDescriptorChangedHandler(YAxisDescriptor sender); public class YAxisDescriptor { private ILabelProvider yAxisLabelProvider = new ContinuousLabelProvider("0.##"); private readonly List dataRows = new List(); private bool showYAxis = true; private string label = ""; public bool ClipChangeable = true; public event YAxisDescriptorChangedHandler YAxisDescriptorChanged; private void OnYAxisDescriptorChanged() { if (YAxisDescriptorChanged != null) { YAxisDescriptorChanged(this); } } public List DataRows { get { return dataRows; } } public bool ShowYAxis { get { return showYAxis; } set { showYAxis = value; OnYAxisDescriptorChanged(); } } public ILabelProvider YAxisLabelProvider { get { return yAxisLabelProvider; } set { yAxisLabelProvider = value; OnYAxisDescriptorChanged(); } } public double MinValue { get { double min = double.MaxValue; foreach (IDataRow row in dataRows) { min = Math.Min(min, row.MinValue); } return min; } } public double MaxValue { get { double max = double.MinValue; foreach (IDataRow row in dataRows) { max = Math.Max(max, row.MaxValue); } return max; } } public string Label { get { return label; } set { label = value; OnYAxisDescriptorChanged(); } } public bool Zoom_ { get { return ClipChangeable; } set { ClipChangeable = value; } } public void AddDataRow(IDataRow row) { if (row.YAxis != null) { row.YAxis.DataRows.Remove(row); } this.DataRows.Add(row); OnYAxisDescriptorChanged(); } } }