Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization/YAxisDescriptor.cs @ 1460

Last change on this file since 1460 was 1460, checked in by bspisic, 15 years ago

YAxisDescriptor.Zoom_ and .ClipChangeable fixed (#559)

File size: 2.7 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 string label = "";
15    public bool clipChangeable = true;
16    private AxisPosition position = AxisPosition.Left;
17
18    private bool showGrid = true;
19    private Color gridColor = Color.LightBlue;
20
21    public event YAxisDescriptorChangedHandler YAxisDescriptorChanged;
22
23    private void OnYAxisDescriptorChanged() {
24      if (YAxisDescriptorChanged != null) {
25        YAxisDescriptorChanged(this);
26      }
27    }
28
29    public List<IDataRow> DataRows {
30      get { return dataRows; }
31    }
32
33    public bool ShowYAxis {
34      get { return showYAxis; }
35      set {
36        showYAxis = value;
37        OnYAxisDescriptorChanged();
38      }
39    }
40
41    public ILabelProvider YAxisLabelProvider {
42      get { return yAxisLabelProvider; }
43      set {
44        yAxisLabelProvider = value;
45        OnYAxisDescriptorChanged();
46      }
47    }
48
49    public double MinValue {
50      get {
51        double min = double.MaxValue;
52
53        foreach (IDataRow row in dataRows) {
54          min = Math.Min(min, row.MinValue);
55        }
56
57        return min;
58      }
59    }
60
61    public double MaxValue {
62      get {
63        double max = double.MinValue;
64
65        foreach (IDataRow row in dataRows) {
66          max = Math.Max(max, row.MaxValue);
67        }
68
69        return max;
70      }
71    }
72
73    public string Label {
74      get { return label; }
75      set {
76        label = value;
77        OnYAxisDescriptorChanged();
78      }
79    }
80
81    public bool ClipChangeable {
82      get { return clipChangeable; }
83      set { clipChangeable = value; }
84    }
85
86    public AxisPosition Position {
87      get { return position; }
88      set {
89        position = value;
90        OnYAxisDescriptorChanged();
91      }
92    }
93
94    public bool ShowGrid {
95      get { return showGrid; }
96      set {
97        showGrid = value;
98        OnYAxisDescriptorChanged();
99      }
100    }
101
102    public Color GridColor {
103      get { return gridColor; }
104      set {
105        gridColor = value;
106        OnYAxisDescriptorChanged();
107      }
108    }
109
110    public void AddDataRow(IDataRow row) {
111      if (row.YAxis != null) {
112        row.YAxis.DataRows.Remove(row);
113      }
114      this.DataRows.Add(row);
115      OnYAxisDescriptorChanged();
116    }
117  }
118}
Note: See TracBrowser for help on using the repository browser.