[1350] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using HeuristicLab.Visualization.LabelProvider;
|
---|
| 4 |
|
---|
| 5 | namespace HeuristicLab.Visualization {
|
---|
| 6 | public delegate void YAxisDescriptorChangedHandler(YAxisDescriptor sender);
|
---|
| 7 |
|
---|
| 8 | public class YAxisDescriptor {
|
---|
| 9 | private ILabelProvider yAxisLabelProvider = new ContinuousLabelProvider("0.##");
|
---|
| 10 | private readonly List<IDataRow> dataRows = new List<IDataRow>();
|
---|
| 11 | private bool showYAxis = true;
|
---|
| 12 | private string label = "";
|
---|
| 13 |
|
---|
| 14 | public event YAxisDescriptorChangedHandler YAxisDescriptorChanged;
|
---|
| 15 |
|
---|
| 16 | private void OnYAxisDescriptorChanged() {
|
---|
| 17 | if (YAxisDescriptorChanged != null) {
|
---|
| 18 | YAxisDescriptorChanged(this);
|
---|
| 19 | }
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | public List<IDataRow> DataRows {
|
---|
| 23 | get { return dataRows; }
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | public bool ShowYAxis {
|
---|
| 27 | get { return showYAxis; }
|
---|
| 28 | set {
|
---|
| 29 | showYAxis = value;
|
---|
| 30 | OnYAxisDescriptorChanged();
|
---|
| 31 | }
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | public ILabelProvider YAxisLabelProvider {
|
---|
| 35 | get { return yAxisLabelProvider; }
|
---|
| 36 | set {
|
---|
| 37 | yAxisLabelProvider = value;
|
---|
| 38 | OnYAxisDescriptorChanged();
|
---|
| 39 | }
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | public double MinValue {
|
---|
| 43 | get {
|
---|
| 44 | double min = double.MaxValue;
|
---|
| 45 |
|
---|
| 46 | foreach (IDataRow row in dataRows) {
|
---|
| 47 | min = Math.Min(min, row.MinValue);
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | return min;
|
---|
| 51 | }
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | public double MaxValue {
|
---|
| 55 | get {
|
---|
| 56 | double max = double.MinValue;
|
---|
| 57 |
|
---|
| 58 | foreach (IDataRow row in dataRows) {
|
---|
| 59 | max = Math.Max(max, row.MaxValue);
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | return max;
|
---|
| 63 | }
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | public string Label {
|
---|
| 67 | get { return label; }
|
---|
| 68 | set {
|
---|
| 69 | label = value;
|
---|
| 70 | OnYAxisDescriptorChanged();
|
---|
| 71 | }
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | public void AddDataRow(IDataRow row) {
|
---|
| 75 | if (row.YAxis != null) {
|
---|
| 76 | row.YAxis.DataRows.Remove(row);
|
---|
| 77 | }
|
---|
| 78 | this.DataRows.Add(row);
|
---|
| 79 | OnYAxisDescriptorChanged();
|
---|
| 80 | }
|
---|
| 81 | }
|
---|
| 82 | } |
---|