[1350] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
[1458] | 3 | using System.Drawing;
|
---|
[1350] | 4 | using HeuristicLab.Visualization.LabelProvider;
|
---|
[1457] | 5 | using HeuristicLab.Visualization.Test;
|
---|
[1350] | 6 |
|
---|
| 7 | namespace HeuristicLab.Visualization {
|
---|
| 8 | public delegate void YAxisDescriptorChangedHandler(YAxisDescriptor sender);
|
---|
| 9 |
|
---|
| 10 | public class YAxisDescriptor {
|
---|
| 11 | private ILabelProvider yAxisLabelProvider = new ContinuousLabelProvider("0.##");
|
---|
| 12 | private readonly List<IDataRow> dataRows = new List<IDataRow>();
|
---|
| 13 | private bool showYAxis = true;
|
---|
[1462] | 14 | private bool showYAxisLabel = true;
|
---|
[1350] | 15 | private string label = "";
|
---|
[1460] | 16 | public bool clipChangeable = true;
|
---|
[1457] | 17 | private AxisPosition position = AxisPosition.Left;
|
---|
[1350] | 18 |
|
---|
[1458] | 19 | private bool showGrid = true;
|
---|
| 20 | private Color gridColor = Color.LightBlue;
|
---|
| 21 |
|
---|
[1350] | 22 | public event YAxisDescriptorChangedHandler YAxisDescriptorChanged;
|
---|
| 23 |
|
---|
| 24 | private void OnYAxisDescriptorChanged() {
|
---|
| 25 | if (YAxisDescriptorChanged != null) {
|
---|
| 26 | YAxisDescriptorChanged(this);
|
---|
| 27 | }
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | public List<IDataRow> DataRows {
|
---|
| 31 | get { return dataRows; }
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | public bool ShowYAxis {
|
---|
| 35 | get { return showYAxis; }
|
---|
| 36 | set {
|
---|
| 37 | showYAxis = value;
|
---|
| 38 | OnYAxisDescriptorChanged();
|
---|
| 39 | }
|
---|
| 40 | }
|
---|
| 41 |
|
---|
[1462] | 42 | public bool ShowYAxisLabel {
|
---|
| 43 | get { return showYAxisLabel; }
|
---|
| 44 | set {
|
---|
| 45 | showYAxisLabel = value;
|
---|
| 46 | OnYAxisDescriptorChanged();
|
---|
| 47 | }
|
---|
| 48 | }
|
---|
| 49 |
|
---|
[1350] | 50 | public ILabelProvider YAxisLabelProvider {
|
---|
| 51 | get { return yAxisLabelProvider; }
|
---|
| 52 | set {
|
---|
| 53 | yAxisLabelProvider = value;
|
---|
| 54 | OnYAxisDescriptorChanged();
|
---|
| 55 | }
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | public double MinValue {
|
---|
| 59 | get {
|
---|
| 60 | double min = double.MaxValue;
|
---|
| 61 |
|
---|
| 62 | foreach (IDataRow row in dataRows) {
|
---|
| 63 | min = Math.Min(min, row.MinValue);
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | return min;
|
---|
| 67 | }
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | public double MaxValue {
|
---|
| 71 | get {
|
---|
| 72 | double max = double.MinValue;
|
---|
| 73 |
|
---|
| 74 | foreach (IDataRow row in dataRows) {
|
---|
| 75 | max = Math.Max(max, row.MaxValue);
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | return max;
|
---|
| 79 | }
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | public string Label {
|
---|
| 83 | get { return label; }
|
---|
| 84 | set {
|
---|
| 85 | label = value;
|
---|
| 86 | OnYAxisDescriptorChanged();
|
---|
| 87 | }
|
---|
| 88 | }
|
---|
| 89 |
|
---|
[1460] | 90 | public bool ClipChangeable {
|
---|
| 91 | get { return clipChangeable; }
|
---|
| 92 | set { clipChangeable = value; }
|
---|
[1390] | 93 | }
|
---|
| 94 |
|
---|
[1457] | 95 | public AxisPosition Position {
|
---|
| 96 | get { return position; }
|
---|
[1458] | 97 | set {
|
---|
| 98 | position = value;
|
---|
| 99 | OnYAxisDescriptorChanged();
|
---|
| 100 | }
|
---|
[1457] | 101 | }
|
---|
| 102 |
|
---|
[1458] | 103 | public bool ShowGrid {
|
---|
| 104 | get { return showGrid; }
|
---|
| 105 | set {
|
---|
| 106 | showGrid = value;
|
---|
| 107 | OnYAxisDescriptorChanged();
|
---|
| 108 | }
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | public Color GridColor {
|
---|
| 112 | get { return gridColor; }
|
---|
| 113 | set {
|
---|
| 114 | gridColor = value;
|
---|
| 115 | OnYAxisDescriptorChanged();
|
---|
| 116 | }
|
---|
| 117 | }
|
---|
| 118 |
|
---|
[1350] | 119 | public void AddDataRow(IDataRow row) {
|
---|
| 120 | if (row.YAxis != null) {
|
---|
| 121 | row.YAxis.DataRows.Remove(row);
|
---|
| 122 | }
|
---|
| 123 | this.DataRows.Add(row);
|
---|
| 124 | OnYAxisDescriptorChanged();
|
---|
| 125 | }
|
---|
| 126 | }
|
---|
| 127 | } |
---|