[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 = "";
|
---|
[1390] | 13 | public bool ClipChangeable = true;
|
---|
[1350] | 14 |
|
---|
| 15 | public event YAxisDescriptorChangedHandler YAxisDescriptorChanged;
|
---|
| 16 |
|
---|
| 17 | private void OnYAxisDescriptorChanged() {
|
---|
| 18 | if (YAxisDescriptorChanged != null) {
|
---|
| 19 | YAxisDescriptorChanged(this);
|
---|
| 20 | }
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | public List<IDataRow> DataRows {
|
---|
| 24 | get { return dataRows; }
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | public bool ShowYAxis {
|
---|
| 28 | get { return showYAxis; }
|
---|
| 29 | set {
|
---|
| 30 | showYAxis = value;
|
---|
| 31 | OnYAxisDescriptorChanged();
|
---|
| 32 | }
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | public ILabelProvider YAxisLabelProvider {
|
---|
| 36 | get { return yAxisLabelProvider; }
|
---|
| 37 | set {
|
---|
| 38 | yAxisLabelProvider = value;
|
---|
| 39 | OnYAxisDescriptorChanged();
|
---|
| 40 | }
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | public double MinValue {
|
---|
| 44 | get {
|
---|
| 45 | double min = double.MaxValue;
|
---|
| 46 |
|
---|
| 47 | foreach (IDataRow row in dataRows) {
|
---|
| 48 | min = Math.Min(min, row.MinValue);
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | return min;
|
---|
| 52 | }
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | public double MaxValue {
|
---|
| 56 | get {
|
---|
| 57 | double max = double.MinValue;
|
---|
| 58 |
|
---|
| 59 | foreach (IDataRow row in dataRows) {
|
---|
| 60 | max = Math.Max(max, row.MaxValue);
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | return max;
|
---|
| 64 | }
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | public string Label {
|
---|
| 68 | get { return label; }
|
---|
| 69 | set {
|
---|
| 70 | label = value;
|
---|
| 71 | OnYAxisDescriptorChanged();
|
---|
| 72 | }
|
---|
| 73 | }
|
---|
| 74 |
|
---|
[1390] | 75 | public bool Zoom_ {
|
---|
| 76 | get { return ClipChangeable; }
|
---|
| 77 | set { ClipChangeable = value; }
|
---|
| 78 | }
|
---|
| 79 |
|
---|
[1350] | 80 | public void AddDataRow(IDataRow row) {
|
---|
| 81 | if (row.YAxis != null) {
|
---|
| 82 | row.YAxis.DataRows.Remove(row);
|
---|
| 83 | }
|
---|
| 84 | this.DataRows.Add(row);
|
---|
| 85 | OnYAxisDescriptorChanged();
|
---|
| 86 | }
|
---|
| 87 | }
|
---|
| 88 | } |
---|