- Timestamp:
- 11/13/08 22:44:22 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Visualization
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization/ChartDataRowsModel.cs
r736 r754 49 49 50 50 public override IView CreateView() { 51 //return new LineChart(this);when LineChart is implemented51 return new LineChart(this); //when LineChart is implemented 52 52 return new IntDataView(test); 53 53 } -
trunk/sources/HeuristicLab.Visualization/ChartDataRowsModelDummy.cs
r727 r754 4 4 using System.Text; 5 5 6 namespace HeuristicLab.Visualization { 7 public class ChartDataRowsModelDummy : ChartDataRowsModel { 6 namespace HeuristicLab.Visualization{ 7 public class ChartDataRowsModelDummy : ChartDataRowsModel { 8 public ChartDataRowsModelDummy(){ 9 Random rand = new Random(); 8 10 9 public ChartDataRowsModelDummy(){ 10 11 // test rows 12 AddDataRow(1); 13 AddDataRow(2); 14 AddDataRow(3); 15 AddDataRow(4); 16 17 PushData(1, 1.2); 18 PushData(1, 2.0); 19 PushData(1, 4.5); 20 PushData(1, 8.4); 21 PushData(1, 5.0); 22 PushData(1, 6.0); 23 PushData(2, 2.0); 24 PushData(3, 8.3); 25 PushData(3, 7.3); 26 PushData(3, 9.7); 27 PushData(3, 2.3); 28 PushData(3, 1.7); 29 PushData(3, 0.3); 30 PushData(3, 0.1); 31 PushData(3, 2.0); 32 PushData(3, 8.8); 33 PushData(3, 9.9); 34 35 } 36 11 12 // test rows 13 for (int i = 0; i < 10; i++){ 14 AddDataRow(i); 15 PushData(i, rand.NextDouble() * 1000); 16 PushData(i, rand.NextDouble() * 1000); 17 PushData(i, rand.NextDouble() * 1000); 18 } 19 } 37 20 } 38 21 } -
trunk/sources/HeuristicLab.Visualization/HeuristicLab.Visualization.csproj
r726 r754 4 4 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 5 5 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> 6 <ProductVersion>9.0. 21022</ProductVersion>6 <ProductVersion>9.0.30729</ProductVersion> 7 7 <SchemaVersion>2.0</SchemaVersion> 8 8 <ProjectGuid>{E392A1E2-DC95-4E33-B82E-8ED690EDA1AB}</ProjectGuid> … … 76 76 <DependentUpon>LineChart.cs</DependentUpon> 77 77 </Compile> 78 <Compile Include="LineShape.cs" /> 78 79 <Compile Include="MouseEventListener.cs" /> 79 80 <Compile Include="Offset.cs" /> -
trunk/sources/HeuristicLab.Visualization/LineChart.Designer.cs
r684 r754 29 29 private void InitializeComponent() 30 30 { 31 this.SuspendLayout(); 32 // 33 // LineChart 34 // 35 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 36 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 37 this.Name = "LineChart"; 38 this.Size = new System.Drawing.Size(552, 390); 39 this.ResumeLayout(false); 31 this.canvasUI1 = new HeuristicLab.Visualization.CanvasUI(); 32 this.SuspendLayout(); 33 // 34 // canvasUI1 35 // 36 this.canvasUI1.Location = new System.Drawing.Point(3, 3); 37 this.canvasUI1.MouseEventListener = null; 38 this.canvasUI1.Name = "canvasUI1"; 39 this.canvasUI1.Size = new System.Drawing.Size(546, 384); 40 this.canvasUI1.TabIndex = 0; 41 this.canvasUI1.Text = "canvasUI1"; 42 // 43 // LineChart 44 // 45 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 46 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 47 this.Controls.Add(this.canvasUI1); 48 this.Name = "LineChart"; 49 this.Size = new System.Drawing.Size(552, 390); 50 this.ResumeLayout(false); 40 51 41 52 } 42 53 43 54 #endregion 55 56 private CanvasUI canvasUI1; 44 57 } 45 58 } -
trunk/sources/HeuristicLab.Visualization/LineChart.cs
r697 r754 1 1 using System; 2 using System.Drawing; 2 3 using HeuristicLab.Core; 3 4 4 namespace HeuristicLab.Visualization { 5 public partial class LineChart : ViewBase { 5 namespace HeuristicLab.Visualization 6 { 7 public partial class LineChart : ViewBase 8 { 6 9 private readonly IChartDataRowsModel model; 10 private Color[] lineColors; 7 11 8 12 /// <summary> 9 13 /// This constructor shouldn't be called. Only required for the designer. 10 14 /// </summary> 11 public LineChart() { 15 public LineChart() 16 { 12 17 InitializeComponent(); 13 18 } … … 16 21 /// Initializes the chart. 17 22 /// </summary> 18 /// <param name="model"></param> 19 public LineChart(IChartDataRowsModel model) : this() { 20 if (model == null) { 23 /// <param name="model">Referenz to the model, for data</param> 24 public LineChart(IChartDataRowsModel model) : this() 25 { 26 if (model == null) 27 { 21 28 throw new NullReferenceException("Model cannot be null."); 22 29 } … … 24 31 this.model = model; 25 32 33 //TODO: read line colors instead of static ones 34 lineColors = new Color[3]; 35 lineColors[0] = Color.Red; 36 lineColors[1] = Color.Green; 37 lineColors[2] = Color.Blue; 38 39 //TODO: correct Rectangle to fit 40 RectangleD clientRectangle = new RectangleD(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Right, 41 ClientRectangle.Bottom); 42 canvasUI1.MainCanvas.WorldShape = new WorldShape(clientRectangle, clientRectangle); 26 43 Reset(); 27 44 } … … 30 47 /// Resets the line chart by deleting all shapes and reloading all data from the model. 31 48 /// </summary> 32 private void Reset() { 49 private void Reset() 50 { 33 51 BeginUpdate(); 34 52 35 53 // TODO clear existing shapes 36 54 55 WorldShape mainWorld = canvasUI1.MainCanvas.WorldShape; 56 57 double spacing = mainWorld.BoundingBox.Width/model.Columns.Count; 58 double oldX = 0; 59 double currentX = spacing; 60 ChartDataRowsModelColumn oldColumn = null; 37 61 // reload data from the model and create shapes 38 foreach (ChartDataRowsModelColumn column in model.Columns) { 39 AddColumn(column.ColumnId, column.Values); 62 foreach (ChartDataRowsModelColumn column in model.Columns) 63 { 64 if (oldColumn != null) 65 { 66 if (column.Values != null) 67 { 68 for (int i = 0; i < column.Values.Length; i++) 69 { 70 LineShape line = new LineShape(oldX, oldColumn.Values[i], currentX, column.Values[i], 0, lineColors[i]); 71 mainWorld.AddShape(line); 72 } 73 oldX = currentX; 74 currentX += spacing; 75 } 76 oldColumn = column; 77 } 78 else 79 { 80 oldColumn = column; 81 } 82 83 canvasUI1.Invalidate(); 84 85 // AddColumn(column.ColumnId, column.Values); 40 86 } 41 87 … … 49 95 /// <param name="columnId">Id of the changed column</param> 50 96 /// <param name="values">Values contained within the changed column</param> 51 private void OnDataChanged(ChangeType type, long columnId, double[] values) { 52 switch (type) { 97 private void OnDataChanged(ChangeType type, long columnId, double[] values) 98 { 99 switch (type) 100 { 53 101 case ChangeType.Add: 54 102 AddColumn(columnId, values); … … 70 118 /// <param name="columnId">Id of the column</param> 71 119 /// <param name="values">Values of the column</param> 72 private void AddColumn(long columnId, double[] values) { 120 private void AddColumn(long columnId, double[] values) 121 { 73 122 throw new NotImplementedException(); 74 123 } … … 79 128 /// <param name="columnId">Id of the column</param> 80 129 /// <param name="values">Values of the column</param> 81 private void ModifyColumn(long columnId, double[] values) { 130 private void ModifyColumn(long columnId, double[] values) 131 { 82 132 throw new NotImplementedException(); 83 133 } … … 87 137 /// </summary> 88 138 /// <param name="columnId">Id of the column</param> 89 private void RemoveColumn(long columnId) { 139 private void RemoveColumn(long columnId) 140 { 90 141 throw new NotImplementedException(); 91 142 } … … 93 144 #region Add-/RemoveItemEvents 94 145 95 protected override void AddItemEvents() { 146 protected override void AddItemEvents() 147 { 96 148 base.AddItemEvents(); 97 149 model.ColumnChanged += OnDataChanged; 98 150 } 99 151 100 protected override void RemoveItemEvents() { 152 protected override void RemoveItemEvents() 153 { 101 154 base.RemoveItemEvents(); 102 155 model.ColumnChanged -= OnDataChanged; … … 109 162 private int beginUpdateCount = 0; 110 163 111 public void BeginUpdate() { 164 public void BeginUpdate() 165 { 112 166 beginUpdateCount++; 113 167 } 114 168 115 public void EndUpdate() { 116 if (beginUpdateCount == 0) { 169 public void EndUpdate() 170 { 171 if (beginUpdateCount == 0) 172 { 117 173 throw new InvalidOperationException("Too many EndUpdates."); 118 174 } … … 120 176 beginUpdateCount--; 121 177 122 if (beginUpdateCount == 0) { 178 if (beginUpdateCount == 0) 179 { 123 180 Invalidate(); 124 181 }
Note: See TracChangeset
for help on using the changeset viewer.