Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization/3.2/YAxisDescriptor.cs @ 1530

Last change on this file since 1530 was 1530, checked in by gkronber, 15 years ago

Moved source files of plugins Hive ... Visualization.Test into version-specific sub-folders. #576

File size: 2.9 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Drawing;
4using HeuristicLab.Visualization.LabelProvider;
5using HeuristicLab.Visualization.Test;
6
7namespace 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;
14    private bool showYAxisLabel = true;
15    private string label = "";
16    public bool clipChangeable = true;
17    private AxisPosition position = AxisPosition.Left;
18
19    private bool showGrid = true;
20    private Color gridColor = Color.LightBlue;
21
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
42    public bool ShowYAxisLabel {
43      get { return showYAxisLabel; }
44      set {
45        showYAxisLabel = value;
46        OnYAxisDescriptorChanged();
47      }
48    }
49
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
90    public bool ClipChangeable {
91      get { return clipChangeable; }
92      set { clipChangeable = value; }
93    }
94
95    public AxisPosition Position {
96      get { return position; }
97      set {
98        position = value;
99        OnYAxisDescriptorChanged();
100      }
101    }
102
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
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}
Note: See TracBrowser for help on using the repository browser.