Changeset 1350
- Timestamp:
- 03/16/09 19:42:17 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 added
- 1 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization.Test/LineChartTestForm.cs
r1249 r1350 4 4 5 5 namespace HeuristicLab.Visualization.Test { 6 public delegate void AddValueHandler(); 7 6 8 public partial class LineChartTestForm : Form { 7 9 private readonly IView view; … … 29 31 } 30 32 33 public event AddValueHandler AddValue; 34 31 35 private void btnAddRandomValue_Click(object sender, EventArgs e) { 32 Random rand = new Random(); 36 if (AddValue != null) { 37 AddValue(); 38 } else { 39 Random rand = new Random(); 33 40 34 foreach (IDataRow row in model.Rows) 35 row.AddValue(rand.NextDouble()*100); 41 foreach (IDataRow row in model.Rows) 42 row.AddValue(rand.NextDouble() * 100); 43 } 36 44 } 37 45 } -
trunk/sources/HeuristicLab.Visualization.Test/LineChartTests.cs
r1343 r1350 77 77 IDataRow row1 = new DataRow(); 78 78 IDataRow row2 = new DataRow(); 79 IDataRow row3 = new DataRow(); 79 80 80 81 row1.Color = Color.Red; … … 88 89 row2.Label = "Die Grüne"; 89 90 91 row3.Color = Color.Blue; 92 row3.Thickness = 3; 93 row3.Style = DrawingStyle.Solid; 94 row3.Label = "Die Blaue"; 95 row3.YAxis = new YAxisDescriptor(); 96 90 97 model.AddDataRow(row1); 91 98 model.AddDataRow(row2); 99 model.AddDataRow(row3); 92 100 93 101 Random rand = new Random(42); 94 102 95 103 for (int i = 0; i < 10; i++) { 96 104 row1.AddValue(rand.NextDouble()*10); 97 105 row2.AddValue(rand.NextDouble()*10); 106 row3.AddValue(rand.NextDouble()*1); 98 107 } 108 109 f.AddValue += delegate { 110 row1.AddValue(rand.NextDouble()*10); 111 row2.AddValue(rand.NextDouble()*10); 112 row3.AddValue(rand.NextDouble()*1); 113 }; 99 114 100 115 f.ShowDialog(); … … 114 129 115 130 116 IAggregator aggregator = new MinAggregator();131 MinAggregator aggregator = new MinAggregator(); 117 132 aggregator.Label = "MinAggregator"; 118 133 aggregator.Color = Color.Pink; … … 173 188 174 189 175 IAggregator aggregator = new MinAggregator();190 MinAggregator aggregator = new MinAggregator(); 176 191 aggregator.Label = "MinAggregator"; 177 192 aggregator.Color = Color.Pink; … … 182 197 model.AddDataRow(aggregator); 183 198 184 IAggregator maxAggregator = new MaxAggregator();199 MaxAggregator maxAggregator = new MaxAggregator(); 185 200 maxAggregator.Label = "MaxAggregator"; 186 201 maxAggregator.Color = Color.DeepSkyBlue; … … 192 207 193 208 194 IAggregator avgAggregator = new AvgAggregator();209 AvgAggregator avgAggregator = new AvgAggregator(); 195 210 avgAggregator.Label = "AvgAggregator"; 196 211 avgAggregator.Color = Color.Violet; … … 201 216 model.AddDataRow(avgAggregator); 202 217 203 IAggregator multiAvgAggregator = new AvgAggregator();218 AvgAggregator multiAvgAggregator = new AvgAggregator(); 204 219 multiAvgAggregator.Label = "MultiAvgAggregator"; 205 220 multiAvgAggregator.Color = Color.DarkOliveGreen; … … 211 226 model.AddDataRow(multiAvgAggregator); 212 227 213 IAggregator multiMaxAggregator = new MaxAggregator();228 MaxAggregator multiMaxAggregator = new MaxAggregator(); 214 229 multiMaxAggregator.Label = "MultiMaxAggregator"; 215 230 multiMaxAggregator.Color = Color.DarkKhaki; … … 221 236 model.AddDataRow(multiMaxAggregator); 222 237 223 IAggregator multiMinAggregator = new MinAggregator();238 MinAggregator multiMinAggregator = new MinAggregator(); 224 239 multiMinAggregator.Label = "MultiMinAggregator"; 225 240 multiMinAggregator.Color = Color.DarkRed; … … 231 246 model.AddDataRow(multiMinAggregator); 232 247 233 IAggregator multiLineAvgAggregator = new AvgLineAggregator();248 AvgLineAggregator multiLineAvgAggregator = new AvgLineAggregator(); 234 249 multiLineAvgAggregator.Label = "MultiLineAvgAggregator"; 235 250 multiLineAvgAggregator.Color = Color.Red; -
trunk/sources/HeuristicLab.Visualization/AvgAggregator.cs
r1343 r1350 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.Drawing;4 3 5 4 namespace HeuristicLab.Visualization { 6 public class AvgAggregator : IAggregator { 7 8 5 public class AvgAggregator : DataRowBase { 9 6 #region IAggregator Members 10 7 … … 17 14 18 15 public void RemoveWatch(IDataRow dataRow) { 19 20 16 dataRowWatches.Remove(dataRow); 21 17 dataRow.DataRowChanged -= dataRow_DataRowChanged; … … 24 20 } 25 21 26 27 22 #endregion 28 23 29 List<IDataRow> dataRowWatches = new List<IDataRow>();30 double curAvgValue;24 private List<IDataRow> dataRowWatches = new List<IDataRow>(); 25 private double curAvgValue; 31 26 32 void dataRow_ValueChanged(IDataRow row, double value, int index, Action action) {27 private void dataRow_ValueChanged(IDataRow row, double value, int index, Action action) { 33 28 refreshValue(value); 34 29 } 35 30 36 void dataRow_ValuesChanged(IDataRow row, double[] values, int index, Action action) {31 private void dataRow_ValuesChanged(IDataRow row, double[] values, int index, Action action) { 37 32 for (int i = 0; i < values.Length; i++) { 38 33 refreshValue(values[i]); … … 40 35 } 41 36 42 void dataRow_DataRowChanged(IDataRow row) {37 private void dataRow_DataRowChanged(IDataRow row) { 43 38 refreshValue(double.MinValue); 44 39 } … … 50 45 double tmpSum = 0; 51 46 int count = 0; 52 foreach ( varrows in dataRowWatches) {47 foreach (IDataRow rows in dataRowWatches) { 53 48 for (int i = 0; i < rows.Count; i++) { 54 49 tmpSum += rows[i]; … … 63 58 #region IDataRow Members 64 59 65 private string label = ""; 66 private Color color = Color.Black; 67 private int thickness = 2; 68 private DrawingStyle style = DrawingStyle.Solid; 69 private DataRowType lineType = DataRowType.Normal; 70 71 72 public string Label { 73 get { return label; } 74 set { 75 label = value; 76 OnDataRowChanged(this); 77 } 78 } 79 80 public Color Color { 81 get { return color; } 82 set { 83 color = value; 84 OnDataRowChanged(this); 85 } 86 } 87 88 public int Thickness { 89 get { return thickness; } 90 set { 91 thickness = value; 92 OnDataRowChanged(this); 93 } 94 } 95 96 public DrawingStyle Style { 97 get { return style; } 98 set { 99 style = value; 100 OnDataRowChanged(this); 101 } 102 } 103 104 public DataRowType LineType { 105 get { return lineType; } 106 set { 107 lineType = value; 108 OnDataRowChanged(this); 109 } 110 } 111 112 private bool showYAxis = false; 113 114 public bool ShowYAxis { 115 get { return showYAxis; } 116 set { 117 showYAxis = value; 118 OnDataRowChanged(this); 119 } 120 } 121 122 public LabelProvider.ILabelProvider YAxisLabelProvider { 123 get { 124 throw new NotImplementedException(); 125 } 126 set { 127 throw new NotImplementedException(); 128 } 129 } 130 131 public void AddValue(double value) { 60 public override void AddValue(double value) { 132 61 throw new NotSupportedException(); 133 62 } 134 63 135 public void AddValue(double value, int index) {64 public override void AddValue(double value, int index) { 136 65 throw new NotSupportedException(); 137 66 } 138 67 139 public void AddValues(double[] values) {68 public override void AddValues(double[] values) { 140 69 throw new NotSupportedException(); 141 70 } 142 71 143 public void AddValues(double[] values, int index) {72 public override void AddValues(double[] values, int index) { 144 73 throw new NotSupportedException(); 145 74 } 146 75 147 public void ModifyValue(double value, int index) {76 public override void ModifyValue(double value, int index) { 148 77 throw new NotSupportedException(); 149 78 } 150 79 151 public void ModifyValues(double[] values, int index) {80 public override void ModifyValues(double[] values, int index) { 152 81 throw new NotSupportedException(); 153 82 } 154 83 155 public void RemoveValue(int index) {84 public override void RemoveValue(int index) { 156 85 throw new NotSupportedException(); 157 86 } 158 87 159 public void RemoveValues(int index, int count) {88 public override void RemoveValues(int index, int count) { 160 89 throw new NotSupportedException(); 161 90 } 162 91 163 public int Count {92 public override int Count { 164 93 get { return 1; } 165 94 } 166 95 167 public double this[int index] { 168 get { 169 return curAvgValue; 170 } 171 set { 172 throw new NotSupportedException(); 173 } 96 public override double this[int index] { 97 get { return curAvgValue; } 98 set { throw new NotSupportedException(); } 174 99 } 175 100 176 public double MinValue {177 get { throw new System.NotImplementedException(); }101 public override double MinValue { 102 get { return curAvgValue; } 178 103 } 179 104 180 public double MaxValue { 181 get { throw new System.NotImplementedException(); } 182 } 183 184 public event ValuesChangedHandler ValuesChanged; 185 186 protected void OnValuesChanged(double[] values, int index, Action action) { 187 if (ValuesChanged != null) { 188 ValuesChanged(this, values, index, action); 189 } 190 } 191 192 public event ValueChangedHandler ValueChanged; 193 194 protected void OnValueChanged(double value, int index, Action action) { 195 if (ValueChanged != null) { 196 ValueChanged(this, value, index, action); 197 } 198 } 199 200 public event DataRowChangedHandler DataRowChanged; 201 202 protected void OnDataRowChanged(IDataRow row) { 203 if (DataRowChanged != null) { 204 DataRowChanged(this); 205 } 105 public override double MaxValue { 106 get { return curAvgValue; } 206 107 } 207 108 -
trunk/sources/HeuristicLab.Visualization/AvgLineAggregator.cs
r1343 r1350 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.Drawing;4 3 5 4 namespace HeuristicLab.Visualization { 6 public class AvgLineAggregator : IAggregator{5 public class AvgLineAggregator : DataRowBase { 7 6 8 7 private readonly List<double> dataRow = new List<double>(); … … 77 76 #region IDataRow Members 78 77 79 private string label = ""; 80 private Color color = Color.Black; 81 private int thickness = 2; 82 private DrawingStyle style = DrawingStyle.Solid; 83 private DataRowType lineType = DataRowType.Normal; 84 85 86 public string Label { 87 get { return label; } 88 set { 89 label = value; 90 OnDataRowChanged(this); 91 } 92 } 93 94 public Color Color { 95 get { return color; } 96 set { 97 color = value; 98 OnDataRowChanged(this); 99 } 100 } 101 102 public int Thickness { 103 get { return thickness; } 104 set { 105 thickness = value; 106 OnDataRowChanged(this); 107 } 108 } 109 110 public DrawingStyle Style { 111 get { return style; } 112 set { 113 style = value; 114 OnDataRowChanged(this); 115 } 116 } 117 118 public DataRowType LineType { 119 get { return lineType; } 120 set { 121 lineType = value; 122 OnDataRowChanged(this); 123 } 124 } 125 126 127 private bool showYAxis = false; 128 129 public bool ShowYAxis { 130 get { return showYAxis; } 131 set { 132 showYAxis = value; 133 OnDataRowChanged(this); 134 } 135 } 136 137 public LabelProvider.ILabelProvider YAxisLabelProvider { 138 get { 139 throw new NotImplementedException(); 140 } 141 set { 142 throw new NotImplementedException(); 143 } 144 } 145 146 public void AddValue(double value) { 78 public override void AddValue(double value) { 147 79 dataRow.Add(value); 148 80 OnValueChanged(value, dataRow.Count - 1, Action.Added); 149 81 } 150 82 151 public void AddValue(double value, int index) {152 throw new System.NotImplementedException();83 public override void AddValue(double value, int index) { 84 throw new NotImplementedException(); 153 85 } 154 86 155 public void AddValues(double[] values) {87 public override void AddValues(double[] values) { 156 88 throw new NotSupportedException(); 157 89 } 158 90 159 public void AddValues(double[] values, int index) {91 public override void AddValues(double[] values, int index) { 160 92 throw new NotSupportedException(); 161 93 } 162 94 163 public void ModifyValue(double value, int index) {95 public override void ModifyValue(double value, int index) { 164 96 throw new NotSupportedException(); 165 97 } 166 98 167 public void ModifyValues(double[] values, int index) {99 public override void ModifyValues(double[] values, int index) { 168 100 throw new NotSupportedException(); 169 101 } 170 102 171 public void RemoveValue(int index) {103 public override void RemoveValue(int index) { 172 104 throw new NotSupportedException(); 173 105 } 174 106 175 public void RemoveValues(int index, int count) {107 public override void RemoveValues(int index, int count) { 176 108 throw new NotSupportedException(); 177 109 } 178 110 179 public int Count {111 public override int Count { 180 112 get { return dataRowWatches.Count; } 181 113 } 182 114 183 public double this[int index] {115 public override double this[int index] { 184 116 get { return dataRow[index]; } 185 117 set { … … 189 121 } 190 122 191 public double MinValue { 192 get { throw new System.NotImplementedException(); } 123 // TODO calculate min value 124 public override double MinValue { 125 get { return 0; } 193 126 } 194 127 195 public double MaxValue { 196 get { throw new System.NotImplementedException(); } 197 } 198 199 public event ValuesChangedHandler ValuesChanged; 200 201 protected void OnValuesChanged(double[] values, int index, Action action) { 202 if (ValuesChanged != null) { 203 ValuesChanged(this, values, index, action); 204 } 205 } 206 207 public event ValueChangedHandler ValueChanged; 208 209 protected void OnValueChanged(double value, int index, Action action) { 210 if (ValueChanged != null) { 211 ValueChanged(this, value, index, action); 212 } 213 } 214 215 public event DataRowChangedHandler DataRowChanged; 216 217 protected void OnDataRowChanged(IDataRow row) { 218 if (DataRowChanged != null) { 219 DataRowChanged(this); 220 } 128 // TODO calculate max value 129 public override double MaxValue { 130 get { return 0; } 221 131 } 222 132 -
trunk/sources/HeuristicLab.Visualization/ChartDataRowsModel.cs
r1341 r1350 28 28 } 29 29 30 public List<YAxisDescriptor> YAxes { 31 get { 32 Dictionary<YAxisDescriptor, object> yaxes = new Dictionary<YAxisDescriptor, object>(); 33 34 foreach (IDataRow row in rows) { 35 yaxes[row.YAxis] = null; 36 } 37 38 return new List<YAxisDescriptor>(yaxes.Keys); 39 } 40 } 41 30 42 31 43 private readonly List<IDataRow> rows = new List<IDataRow>(); … … 111 123 //} 112 124 125 private readonly YAxisDescriptor defaultYAxisDescriptor = new YAxisDescriptor(); 126 113 127 public void AddDataRow(IDataRow row) { 128 if (row.YAxis == null) { 129 row.YAxis = defaultYAxisDescriptor; 130 } 114 131 rows.Add(row); 115 132 OnDataRowAdded(row); -
trunk/sources/HeuristicLab.Visualization/DataRow.cs
r1343 r1350 15 15 public delegate void ValueChangedHandler(IDataRow row, double value, int index, Action action); 16 16 17 public class DataRow : IDataRow { 18 private string label = ""; 19 private Color color = Color.Black; 20 private int thickness = 2; 21 private DrawingStyle style = DrawingStyle.Solid; 22 private DataRowType lineType = DataRowType.Normal; 17 public class DataRow : DataRowBase { 23 18 private readonly List<double> dataRow = new List<double>(); 24 25 private ILabelProvider labelProvider = new ContinuousLabelProvider("0.##");26 19 27 20 // TODO implement calculation of min and max values 28 21 private double minValue = double.MaxValue; 29 22 private double maxValue = double.MinValue; 30 31 public DataRowType LineType{32 get { return lineType; }33 set {34 lineType = value;35 OnDataRowChanged(this);36 }37 }38 39 public ILabelProvider YAxisLabelProvider {40 get { return labelProvider; }41 set {42 this.labelProvider = value;43 OnDataRowChanged(this);44 }45 }46 23 47 24 public DataRow() { … … 60 37 } 61 38 62 public event DataRowChangedHandler DataRowChanged; 63 64 protected void OnDataRowChanged(IDataRow row) { 65 if (DataRowChanged != null) { 66 DataRowChanged(this); 67 } 68 } 69 70 public event ValuesChangedHandler ValuesChanged; 71 72 protected void OnValuesChanged(double[] values, int index, Action action) { 73 if (ValuesChanged != null) { 74 ValuesChanged(this, values, index, action); 75 } 76 } 77 78 public event ValueChangedHandler ValueChanged; 79 80 protected void OnValueChanged(double value, int index, Action action) { 81 if (ValueChanged != null) { 82 ValueChanged(this, value, index, action); 83 } 84 } 85 86 public string Label { 87 get { return label; } 88 set { 89 label = value; 90 OnDataRowChanged(this); 91 } 92 } 93 94 95 public Color Color { 96 get { return color; } 97 set { 98 color = value; 99 OnDataRowChanged(this); 100 } 101 } 102 103 public int Thickness { 104 get { return thickness; } 105 set { 106 thickness = value; 107 OnDataRowChanged(this); 108 } 109 } 110 111 public DrawingStyle Style { 112 get { return style; } 113 set { 114 style = value; 115 OnDataRowChanged(this); 116 } 117 } 118 119 private bool showYAxis = true; 120 121 public virtual bool ShowYAxis { 122 get { return showYAxis; } 123 set { 124 showYAxis = value; 125 OnDataRowChanged(this); 126 } 127 } 128 129 public void AddValue(double value) { 39 public override void AddValue(double value) { 130 40 UpdateMinMaxValue(value); 131 41 … … 134 44 } 135 45 136 public void AddValue(double value, int index) {46 public override void AddValue(double value, int index) { 137 47 //check if index is valid 138 48 if (index >= 0 && index < dataRow.Count) { … … 144 54 } 145 55 146 public void AddValues(double[] values) {56 public override void AddValues(double[] values) { 147 57 int startInd = dataRow.Count; 148 58 … … 153 63 } 154 64 155 public void AddValues(double[] values, int index) {65 public override void AddValues(double[] values, int index) { 156 66 int j = index; 157 67 … … 168 78 } 169 79 170 public void ModifyValue(double value, int index) {80 public override void ModifyValue(double value, int index) { 171 81 //check if index is valid 172 82 if (index >= 0 && index < dataRow.Count) { … … 178 88 } 179 89 180 public void ModifyValues(double[] values, int index) {90 public override void ModifyValues(double[] values, int index) { 181 91 int startInd = index; 182 92 int modInd = index; … … 194 104 } 195 105 196 public void RemoveValue(int index) {106 public override void RemoveValue(int index) { 197 107 double remVal = dataRow[index]; 198 108 //check if index is valid … … 205 115 } 206 116 207 public void RemoveValues(int index, int count) {117 public override void RemoveValues(int index, int count) { 208 118 double[] remValues = new double[count]; //removed values 209 119 int j = 0; … … 227 137 } 228 138 229 public int Count {139 public override int Count { 230 140 get { return dataRow.Count; } 231 141 } 232 142 233 public double this[int index] {143 public override double this[int index] { 234 144 get { return dataRow[index]; } 235 145 set { … … 239 149 } 240 150 241 public double MinValue {151 public override double MinValue { 242 152 get { return minValue; } 243 153 } 244 154 245 public double MaxValue {155 public override double MaxValue { 246 156 get { return maxValue; } 247 157 } -
trunk/sources/HeuristicLab.Visualization/HeuristicLab.Visualization.csproj
r1341 r1350 4 4 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 5 5 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> 6 <ProductVersion>9.0. 30729</ProductVersion>6 <ProductVersion>9.0.21022</ProductVersion> 7 7 <SchemaVersion>2.0</SchemaVersion> 8 8 <ProjectGuid>{E392A1E2-DC95-4E33-B82E-8ED690EDA1AB}</ProjectGuid> … … 84 84 <Compile Include="CompositeShape.cs" /> 85 85 <Compile Include="ChartDataRowsModelDataCollector.cs" /> 86 <Compile Include=" IAggregator.cs" />86 <Compile Include="DataRowBase.cs" /> 87 87 <Compile Include="LabelProvider\ContinuousLabelProvider.cs" /> 88 88 <Compile Include="LabelProvider\DiscreteLabelProvider.cs" /> … … 130 130 <Compile Include="XAxis.cs" /> 131 131 <Compile Include="YAxis.cs" /> 132 <Compile Include="YAxisDescriptor.cs" /> 132 133 <Compile Include="ZoomListener.cs" /> 133 134 </ItemGroup> -
trunk/sources/HeuristicLab.Visualization/IChartDataRowsModel.cs
r1341 r1350 7 7 public interface IChartDataRowsModel : IItem { 8 8 string Title { get; set; } 9 //string XAxisLabel { get; set; }10 //List<string> XLabels { get; }11 9 List<IDataRow> Rows { get; } 12 10 ILabelProvider XAxisLabelProvider { get; set; } 13 11 12 List<YAxisDescriptor> YAxes { get; } 13 14 14 void AddDataRow(IDataRow row); 15 15 void RemoveDataRow(IDataRow row); 16 17 //void AddLabel(string label);18 //void AddLabel(string label, int index);19 //void AddLabels(string[] labels);20 //void AddLabels(string[] labels, int index);21 //void ModifyLabel(string label, int index);22 //void ModifyLabels(string[] labels, int index);23 //void RemoveLabel(int index);24 //void RemoveLabels(int index, int count);25 16 26 17 int MaxDataRowValues { get; } -
trunk/sources/HeuristicLab.Visualization/IDataRow.cs
r1343 r1350 1 1 using System.Drawing; 2 using HeuristicLab.Visualization.LabelProvider;3 2 4 3 namespace HeuristicLab.Visualization { 5 6 4 public enum DataRowType { 7 5 Normal, SingleValue … … 15 13 DataRowType LineType { get; set; } 16 14 17 bool ShowYAxis { get; set; } 18 ILabelProvider YAxisLabelProvider { get; set; } 19 20 /// <summary> 21 /// Raised when data row data changed. Should cause redraw in the view. 22 /// </summary> 15 YAxisDescriptor YAxis { get; set; } 23 16 24 17 void AddValue(double value); -
trunk/sources/HeuristicLab.Visualization/LineChart.cs
r1346 r1350 29 29 private const int XAxisHeight = 20; 30 30 31 private bool zoomToFullView;32 33 34 31 /// <summary> 35 32 /// This constructor shouldn't be called. Only required for the designer. … … 86 83 canvas.ClearShapes(); 87 84 88 foreach (RowEntry rowEntry in rowEntries) { 89 canvas.AddShape(rowEntry.Grid); 85 foreach (YAxisDescriptor yAxisDescriptor in model.YAxes) { 86 YAxisInfo info = GetYAxisInfo(yAxisDescriptor); 87 canvas.AddShape(info.Grid); 90 88 } 91 89 … … 98 96 int yAxesWidth = 0; 99 97 100 foreach (RowEntry rowEntry in rowEntries) { 101 if (rowEntry.DataRow.ShowYAxis) { 102 canvas.AddShape(rowEntry.YAxis); 98 foreach (YAxisDescriptor yAxisDescriptor in model.YAxes) { 99 YAxisInfo info = GetYAxisInfo(yAxisDescriptor); 100 if (yAxisDescriptor.ShowYAxis) { 101 canvas.AddShape(info.YAxis); 103 102 yAxesWidth += YAxisWidth; 104 103 } … … 120 119 foreach (RowEntry rowEntry in rowEntries) { 121 120 rowEntry.LinesShape.BoundingBox = linesAreaBoundingBox; 122 rowEntry.Grid.BoundingBox = linesAreaBoundingBox; 121 } 122 123 foreach (YAxisDescriptor yAxisDescriptor in model.YAxes) { 124 YAxisInfo info = GetYAxisInfo(yAxisDescriptor); 125 info.Grid.BoundingBox = linesAreaBoundingBox; 123 126 } 124 127 125 128 int yAxisLeft = 0; 126 foreach (RowEntry rowEntry in rowEntries) { 127 if (rowEntry.DataRow.ShowYAxis) { 128 rowEntry.YAxis.BoundingBox = new RectangleD(yAxisLeft, 129 linesAreaBoundingBox.Y1, 130 yAxisLeft + YAxisWidth, 131 linesAreaBoundingBox.Y2); 129 foreach (YAxisDescriptor yAxisDescriptor in model.YAxes) { 130 YAxisInfo info = GetYAxisInfo(yAxisDescriptor); 131 if (yAxisDescriptor.ShowYAxis) { 132 info.YAxis.BoundingBox = new RectangleD(yAxisLeft, 133 linesAreaBoundingBox.Y1, 134 yAxisLeft + YAxisWidth, 135 linesAreaBoundingBox.Y2); 132 136 yAxisLeft += YAxisWidth; 133 137 } … … 143 147 144 148 SetLegendPosition(); 149 } 150 151 private readonly Dictionary<YAxisDescriptor, YAxisInfo> yAxisInfos = new Dictionary<YAxisDescriptor, YAxisInfo>(); 152 153 private YAxisInfo GetYAxisInfo(YAxisDescriptor yAxisDescriptor) { 154 YAxisInfo info; 155 156 if (!yAxisInfos.TryGetValue(yAxisDescriptor, out info)) { 157 info = new YAxisInfo(); 158 yAxisInfos[yAxisDescriptor] = info; 159 } 160 161 return info; 162 } 163 164 private void UpdateYAxisInfo(YAxisDescriptor yAxisDescriptor) { 165 // if (yAxisInfos.ContainsKey(yAxisDescriptor)) { 166 // yAxisInfos.Remove(yAxisDescriptor); 167 // } 145 168 } 146 169 … … 206 229 private void optionsToolStripMenuItem_Click(object sender, EventArgs e) { 207 230 OptionsDialog optionsdlg = new OptionsDialog(model); 208 //var optionsdlg = new OptionsDialog(model, this);209 231 optionsdlg.ShowDialog(this); 210 232 Invalidate(); … … 212 234 213 235 public void OnDataRowChanged(IDataRow row) { 236 UpdateYAxisInfo(row.YAxis); 237 214 238 RowEntry rowEntry = rowToRowEntry[row]; 215 239 … … 273 297 274 298 foreach (RowEntry rowEntry in rowEntries) { 275 IDataRow row = rowEntry.DataRow;299 YAxisDescriptor yAxisDescriptor = rowEntry.DataRow.YAxis; 276 300 277 301 SetClipY(rowEntry, 278 row.MinValue - ((row.MaxValue - row.MinValue)*0.05), 279 row.MaxValue + ((row.MaxValue - row.MinValue)*0.05)); 280 } 281 282 zoomToFullView = true; 302 yAxisDescriptor.MinValue - ((yAxisDescriptor.MaxValue - yAxisDescriptor.MinValue)*0.05), 303 yAxisDescriptor.MaxValue + ((yAxisDescriptor.MaxValue - yAxisDescriptor.MinValue)*0.05)); 304 } 283 305 284 306 canvasUI.Invalidate(); … … 296 318 x2, 297 319 rowEntry.LinesShape.ClippingArea.Y2); 298 rowEntry.Grid.ClippingArea = new RectangleD(x1, 299 rowEntry.Grid.ClippingArea.Y1, 300 x2, 301 rowEntry.Grid.ClippingArea.Y2); 302 rowEntry.YAxis.ClippingArea = new RectangleD(0, 303 rowEntry.YAxis.ClippingArea.Y1, 304 YAxisWidth, 305 rowEntry.YAxis.ClippingArea.Y2); 306 } 307 } 308 309 private static void SetClipY(RowEntry rowEntry, double y1, double y2) { 320 } 321 322 foreach (YAxisDescriptor yAxisDescriptor in model.YAxes) { 323 YAxisInfo info = GetYAxisInfo(yAxisDescriptor); 324 info.Grid.ClippingArea = new RectangleD(x1, 325 info.Grid.ClippingArea.Y1, 326 x2, 327 info.Grid.ClippingArea.Y2); 328 info.YAxis.ClippingArea = new RectangleD(0, 329 info.YAxis.ClippingArea.Y1, 330 YAxisWidth, 331 info.YAxis.ClippingArea.Y2); 332 } 333 } 334 335 private void SetClipY(RowEntry rowEntry, double y1, double y2) { 310 336 rowEntry.LinesShape.ClippingArea = new RectangleD(rowEntry.LinesShape.ClippingArea.X1, 311 337 y1, 312 338 rowEntry.LinesShape.ClippingArea.X2, 313 339 y2); 314 rowEntry.Grid.ClippingArea = new RectangleD(rowEntry.Grid.ClippingArea.X1, 315 y1, 316 rowEntry.Grid.ClippingArea.X2, 317 y2); 318 rowEntry.YAxis.ClippingArea = new RectangleD(rowEntry.YAxis.ClippingArea.X1, 319 y1, 320 rowEntry.YAxis.ClippingArea.X2, 321 y2); 340 341 YAxisInfo info = GetYAxisInfo(rowEntry.DataRow.YAxis); 342 343 info.Grid.ClippingArea = new RectangleD(info.Grid.ClippingArea.X1, 344 y1, 345 info.Grid.ClippingArea.X2, 346 y2); 347 info.YAxis.ClippingArea = new RectangleD(info.YAxis.ClippingArea.X1, 348 y1, 349 info.YAxis.ClippingArea.X2, 350 y2); 322 351 } 323 352 … … 418 447 419 448 private void Pan(Point startPoint, Point endPoint) { 420 zoomToFullView = false;421 422 449 foreach (RowEntry rowEntry in rowEntries) { 423 450 RectangleD clippingArea = CalcPanClippingArea(startPoint, endPoint, rowEntry.LinesShape); … … 431 458 432 459 private void PanEnd(Point startPoint, Point endPoint) { 433 zoomToFullView = false;434 435 460 foreach (RowEntry rowEntry in rowEntries) { 436 461 RectangleD clippingArea = CalcPanClippingArea(startPoint, endPoint, rowEntry.LinesShape); … … 552 577 private readonly IDataRow dataRow; 553 578 579 private readonly LinesShape linesShape = new LinesShape(); 580 581 public RowEntry(IDataRow dataRow) { 582 this.dataRow = dataRow; 583 } 584 585 public IDataRow DataRow { 586 get { return dataRow; } 587 } 588 589 public LinesShape LinesShape { 590 get { return linesShape; } 591 } 592 } 593 594 private class YAxisInfo { 554 595 private readonly Grid grid = new Grid(); 555 596 private readonly YAxis yAxis = new YAxis(); 556 private readonly LinesShape linesShape = new LinesShape();557 558 public RowEntry(IDataRow dataRow) {559 this.dataRow = dataRow;560 }561 562 public IDataRow DataRow {563 get { return dataRow; }564 }565 597 566 598 public Grid Grid { … … 571 603 get { return yAxis; } 572 604 } 573 574 public LinesShape LinesShape {575 get { return linesShape; }576 }577 605 } 578 606 } -
trunk/sources/HeuristicLab.Visualization/MaxAggregator.cs
r1343 r1350 4 4 5 5 namespace HeuristicLab.Visualization { 6 public class MaxAggregator : IAggregator { 7 8 6 public class MaxAggregator : DataRowBase { 9 7 #region IAggregator Members 10 8 … … 51 49 } else { 52 50 curMaxValue = double.MinValue; 53 foreach ( varrows in dataRowWatches) {51 foreach (IDataRow rows in dataRowWatches) { 54 52 for (int i = 0; i < rows.Count; i++) { 55 53 if (rows[i] > curMaxValue) { … … 65 63 66 64 #region IDataRow Members 67 68 private string label = ""; 69 private Color color = Color.Black; 70 private int thickness = 2; 71 private DrawingStyle style = DrawingStyle.Solid; 72 private DataRowType lineType = DataRowType.Normal; 73 74 75 public string Label { 76 get { return label; } 77 set { 78 label = value; 79 OnDataRowChanged(this); 80 } 81 } 82 83 public Color Color { 84 get { return color; } 85 set { 86 color = value; 87 OnDataRowChanged(this); 88 } 89 } 90 91 public int Thickness { 92 get { return thickness; } 93 set { 94 thickness = value; 95 OnDataRowChanged(this); 96 } 97 } 98 99 public DrawingStyle Style { 100 get { return style; } 101 set { 102 style = value; 103 OnDataRowChanged(this); 104 } 105 } 106 107 public DataRowType LineType { 108 get { return lineType; } 109 set { 110 lineType = value; 111 OnDataRowChanged(this); 112 } 113 } 114 115 private bool showYAxis = false; 116 117 public bool ShowYAxis { 118 get { return showYAxis; } 119 set { 120 showYAxis = value; 121 OnDataRowChanged(this); 122 } 123 } 124 125 public LabelProvider.ILabelProvider YAxisLabelProvider { 126 get { 127 throw new NotImplementedException(); 128 } 129 set { 130 throw new NotImplementedException(); 131 } 132 } 133 134 public void AddValue(double value) { 65 public override void AddValue(double value) { 135 66 OnValueChanged(2, 0, Action.Added); 136 67 } 137 68 138 public void AddValue(double value, int index) {69 public override void AddValue(double value, int index) { 139 70 throw new NotSupportedException(); 140 71 } 141 72 142 public void AddValues(double[] values) {73 public override void AddValues(double[] values) { 143 74 throw new NotSupportedException(); 144 75 } 145 76 146 public void AddValues(double[] values, int index) {77 public override void AddValues(double[] values, int index) { 147 78 throw new NotSupportedException(); 148 79 } 149 80 150 public void ModifyValue(double value, int index) {81 public override void ModifyValue(double value, int index) { 151 82 throw new NotSupportedException(); 152 83 } 153 84 154 public void ModifyValues(double[] values, int index) {85 public override void ModifyValues(double[] values, int index) { 155 86 throw new NotSupportedException(); 156 87 } 157 88 158 public void RemoveValue(int index) {89 public override void RemoveValue(int index) { 159 90 throw new NotSupportedException(); 160 91 } 161 92 162 public void RemoveValues(int index, int count) {93 public override void RemoveValues(int index, int count) { 163 94 throw new NotSupportedException(); 164 95 } 165 96 166 public int Count {97 public override int Count { 167 98 get { return 1; } 168 99 } 169 100 170 public double this[int index] {101 public override double this[int index] { 171 102 get { 172 103 return curMaxValue; … … 177 108 } 178 109 179 public double MinValue {180 get { throw new System.NotImplementedException(); }110 public override double MinValue { 111 get { return curMaxValue; } 181 112 } 182 113 183 public double MaxValue { 184 get { throw new System.NotImplementedException(); } 185 } 186 187 public event ValuesChangedHandler ValuesChanged; 188 189 protected void OnValuesChanged(double[] values, int index, Action action) { 190 if (ValuesChanged != null) { 191 ValuesChanged(this, values, index, action); 192 } 193 } 194 195 public event ValueChangedHandler ValueChanged; 196 197 protected void OnValueChanged(double value, int index, Action action) { 198 if (ValueChanged != null) { 199 ValueChanged(this, value, index, action); 200 } 201 } 202 203 public event DataRowChangedHandler DataRowChanged; 204 205 protected void OnDataRowChanged(IDataRow row) { 206 if (DataRowChanged != null) { 207 DataRowChanged(this); 208 } 114 public override double MaxValue { 115 get { return curMaxValue; } 209 116 } 210 117 -
trunk/sources/HeuristicLab.Visualization/MinAggregator.cs
r1343 r1350 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.Drawing;4 using HeuristicLab.Visualization.LabelProvider;5 3 6 4 namespace HeuristicLab.Visualization { 7 public class MinAggregator : IAggregator{5 public class MinAggregator : DataRowBase { 8 6 #region IAggregator Members 9 7 … … 50 48 } else { 51 49 curMinValue = double.MaxValue; 52 foreach ( varrows in dataRowWatches) {50 foreach (IDataRow rows in dataRowWatches) { 53 51 for (int i = 0; i < rows.Count; i++) { 54 52 if (rows[i] < curMinValue) { … … 65 63 #region IDataRow Members 66 64 67 private string label = ""; 68 private Color color = Color.Black; 69 private int thickness = 2; 70 private DrawingStyle style = DrawingStyle.Solid; 71 private DataRowType lineType = DataRowType.Normal; 72 73 74 public string Label { 75 get { return label; } 76 set { 77 label = value; 78 OnDataRowChanged(this); 79 } 80 } 81 82 public Color Color { 83 get { return color; } 84 set { 85 color = value; 86 OnDataRowChanged(this); 87 } 88 } 89 90 public int Thickness { 91 get { return thickness; } 92 set { 93 thickness = value; 94 OnDataRowChanged(this); 95 } 96 } 97 98 public DrawingStyle Style { 99 get { return style; } 100 set { 101 style = value; 102 OnDataRowChanged(this); 103 } 104 } 105 106 public DataRowType LineType { 107 get { return lineType; } 108 set { 109 lineType = value; 110 OnDataRowChanged(this); 111 } 112 } 113 114 115 private bool showYAxis = false; 116 117 public bool ShowYAxis { 118 get { return showYAxis; } 119 set { 120 showYAxis = value; 121 OnDataRowChanged(this); 122 } 123 } 124 125 private ILabelProvider labelProvider = new ContinuousLabelProvider("0.##"); 126 public ILabelProvider YAxisLabelProvider { 127 get { return labelProvider; } 128 set { 129 this.labelProvider = value; 130 OnDataRowChanged(this); 131 } 132 } 133 134 public void AddValue(double value) { 65 public override void AddValue(double value) { 135 66 OnValueChanged(2, 0, Action.Added); 136 67 } 137 68 138 public void AddValue(double value, int index) {69 public override void AddValue(double value, int index) { 139 70 throw new NotSupportedException(); 140 71 } 141 72 142 public void AddValues(double[] values) {73 public override void AddValues(double[] values) { 143 74 throw new NotSupportedException(); 144 75 } 145 76 146 public void AddValues(double[] values, int index) {77 public override void AddValues(double[] values, int index) { 147 78 throw new NotSupportedException(); 148 79 } 149 80 150 public void ModifyValue(double value, int index) {81 public override void ModifyValue(double value, int index) { 151 82 throw new NotSupportedException(); 152 83 } 153 84 154 public void ModifyValues(double[] values, int index) {85 public override void ModifyValues(double[] values, int index) { 155 86 throw new NotSupportedException(); 156 87 } 157 88 158 public void RemoveValue(int index) {89 public override void RemoveValue(int index) { 159 90 throw new NotSupportedException(); 160 91 } 161 92 162 public void RemoveValues(int index, int count) {93 public override void RemoveValues(int index, int count) { 163 94 throw new NotSupportedException(); 164 95 } 165 96 166 public int Count {97 public override int Count { 167 98 get { return 1; } 168 99 } 169 100 170 public double this[int index] {101 public override double this[int index] { 171 102 get { 172 103 return curMinValue; … … 177 108 } 178 109 179 public double MinValue {180 get { throw new System.NotImplementedException(); }110 public override double MinValue { 111 get { return curMinValue; } 181 112 } 182 113 183 public double MaxValue { 184 get { throw new System.NotImplementedException(); } 185 } 186 187 public event ValuesChangedHandler ValuesChanged; 188 189 protected void OnValuesChanged(double[] values, int index, Action action) { 190 if (ValuesChanged != null) { 191 ValuesChanged(this, values, index, action); 192 } 193 } 194 195 public event ValueChangedHandler ValueChanged; 196 197 protected void OnValueChanged(double value, int index, Action action) { 198 if (ValueChanged != null) { 199 ValueChanged(this, value, index, action); 200 } 201 } 202 203 public event DataRowChangedHandler DataRowChanged; 204 205 protected void OnDataRowChanged(IDataRow row) { 206 if (DataRowChanged != null) { 207 DataRowChanged(this); 208 } 114 public override double MaxValue { 115 get { return curMinValue; } 209 116 } 210 117 -
trunk/sources/HeuristicLab.Visualization/Options/OptionsDialog.cs
r1345 r1350 52 52 53 53 private void InitTabPageYAxes() { 54 for (int i = 0; i < model. Rows.Count; i++) {55 IDataRow row = model.Rows[i];54 for (int i = 0; i < model.YAxes.Count; i++) { 55 YAxisDescriptor yAxisDescriptor = model.YAxes[i]; 56 56 57 57 CheckBox chkbox = new CheckBox(); 58 chkbox.Text = row.Label;59 chkbox.Checked = row.ShowYAxis;60 chkbox.CheckedChanged += delegate { row.ShowYAxis = chkbox.Checked; };58 chkbox.Text = yAxisDescriptor.Label; 59 chkbox.Checked = yAxisDescriptor.ShowYAxis; 60 chkbox.CheckedChanged += delegate { yAxisDescriptor.ShowYAxis = chkbox.Checked; }; 61 61 62 62 dataRowsFlowLayout.Controls.Add(chkbox);
Note: See TracChangeset
for help on using the changeset viewer.