Changeset 1242 for trunk/sources/HeuristicLab.Visualization/LineChart.cs
- Timestamp:
- 03/03/09 20:10:48 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization/LineChart.cs
r1240 r1242 10 10 public partial class LineChart : ViewBase { 11 11 internal class LinesShape : WorldShape {} 12 13 12 private readonly IChartDataRowsModel model; 14 13 private readonly Canvas canvas; … … 18 17 private double minDataValue; 19 18 private double maxDataValue; 20 private bool minMaxLineEnabled; 21 private MinMaxLineShape minMaxLineShape; 22 private IShape minLineShape; 19 23 20 24 21 private readonly TextShape titleShape; … … 49 46 } 50 47 51 minMaxLineEnabled = true; 52 48 53 49 canvas = canvasUI.Canvas; 54 50 … … 68 64 canvas.AddShape(titleShape); 69 65 70 minMaxLineShape = new MinMaxLineShape(this.minDataValue,this.maxDataValue, Color.Yellow, 4, DrawingStyle.Solid);71 canvas.AddShape(minMaxLineShape);66 // horizontalLineShape = new HorizontalLineShape(this.maxDataValue, Color.Yellow, 4, DrawingStyle.Solid); 67 // root.AddShape(horizontalLineShape); 72 68 73 69 legendShape = new LegendShape(); … … 111 107 grid.BoundingBox = linesShape.BoundingBox; 112 108 113 minMaxLineShape.BoundingBox = linesShape.BoundingBox;114 109 115 110 yAxis.BoundingBox = new RectangleD(0, … … 135 130 } 136 131 132 private void optionsToolStripMenuItem_Click(object sender, EventArgs e) { 133 var optionsdlg = new OptionsDialog(this.model); 134 optionsdlg.ShowDialog(this); 135 } 136 137 public void OnDataRowChanged(IDataRow row) { 138 foreach (LineShape ls in rowToLineShapes[row]) { 139 ls.LSColor = row.Color; 140 ls.LSThickness = row.Thickness; 141 ls.LSDrawingStyle = row.Style; 142 } 143 canvasUI.Invalidate(); 144 } 145 137 146 #region Add-/RemoveItemEvents 147 148 private readonly IDictionary<IDataRow, List<LineShape>> rowToLineShapes = 149 new Dictionary<IDataRow, List<LineShape>>(); 138 150 139 151 protected override void AddItemEvents() { … … 164 176 if (row.Count > maxDataRowCount) { 165 177 maxDataRowCount = row.Count; 178 // UpdateSingleValueRows(); 166 179 } 167 180 … … 183 196 return; 184 197 } 185 RectangleDnewClippingArea = new RectangleD(-0.1,186 187 188 198 var newClippingArea = new RectangleD(-0.1, 199 minDataValue - ((maxDataValue - minDataValue)*0.05), 200 maxDataRowCount - 0.9, 201 maxDataValue + ((maxDataValue - minDataValue)*0.05)); 189 202 190 203 SetLineClippingArea(newClippingArea); … … 201 214 grid.ClippingArea = linesShape.ClippingArea; 202 215 203 minMaxLineShape.ClippingArea = linesShape.ClippingArea; 216 // horizontalLineShape.ClippingArea = linesShape.ClippingArea; 217 204 218 205 219 xAxis.ClippingArea = new RectangleD(linesShape.ClippingArea.X1, … … 215 229 216 230 private void InitLineShapes(IDataRow row) { 217 List<LineShape>lineShapes = new List<LineShape>();231 var lineShapes = new List<LineShape>(); 218 232 if (rowToLineShapes.Count == 0) { 219 233 minDataValue = Double.PositiveInfinity; 220 234 maxDataValue = Double.NegativeInfinity; 221 235 } 222 if ( row.Count > 0) {236 if ((row.Count > 0)) { 223 237 maxDataValue = Math.Max(row[0], maxDataValue); 224 238 minDataValue = Math.Min(row[0], minDataValue); 225 239 } 226 for (int i = 1; i < row.Count; i++) { 227 LineShape lineShape = new LineShape(i - 1, row[i - 1], i, row[i], row.Color, row.Thickness, row.Style); 228 lineShapes.Add(lineShape); 229 // TODO each DataRow needs its own WorldShape so Y Axes can be zoomed independently. 230 linesShape.AddShape(lineShape); 231 maxDataValue = Math.Max(row[i], maxDataValue); 232 minDataValue = Math.Min(row[i], minDataValue); 233 } 234 minMaxLineShape.YMax = maxDataValue; 235 minMaxLineShape.YMin = minDataValue; 240 if ((row.LineType == DataRowType.SingleValue)) { 241 if (row.Count > 0) { 242 LineShape lineShape = new HorizontalLineShape(0, row[0], double.MaxValue, row[0], row.Color, row.Thickness, 243 row.Style); 244 lineShapes.Add(lineShape); 245 // TODO each DataRow needs its own WorldShape so Y Axes can be zoomed independently. 246 linesShape.AddShape(lineShape); 247 } 248 } 249 else { 250 for (int i = 1; i < row.Count; i++) { 251 var lineShape = new LineShape(i - 1, row[i - 1], i, row[i], row.Color, row.Thickness, row.Style); 252 lineShapes.Add(lineShape); 253 // TODO each DataRow needs its own WorldShape so Y Axes can be zoomed independently. 254 linesShape.AddShape(lineShape); 255 maxDataValue = Math.Max(row[i], maxDataValue); 256 minDataValue = Math.Min(row[i], minDataValue); 257 } 258 } 259 //horizontalLineShape.YVal = maxDataValue; 236 260 rowToLineShapes[row] = lineShapes; 237 261 ZoomToFullView(); … … 239 263 canvasUI.Invalidate(); 240 264 } 241 242 private readonly IDictionary<IDataRow, List<LineShape>> rowToLineShapes =243 new Dictionary<IDataRow, List<LineShape>>();244 265 245 266 // TODO use action parameter … … 248 269 maxDataValue = Math.Max(value, maxDataValue); 249 270 minDataValue = Math.Min(value, minDataValue); 250 minMaxLineShape.YMax = maxDataValue; 251 minMaxLineShape.YMin = minDataValue; 252 if (index > lineShapes.Count + 1) { 253 throw new NotImplementedException(); 254 } 255 256 // new value was added 257 if (index > 0 && index == lineShapes.Count + 1) { 258 if (maxDataRowCount < row.Count) { 259 maxDataRowCount = row.Count; 260 } 261 LineShape lineShape = new LineShape(index - 1, row[index - 1], index, row[index], row.Color, row.Thickness, 262 row.Style); 263 lineShapes.Add(lineShape); 264 // TODO each DataRow needs its own WorldShape so Y Axes can be zoomed independently. 265 linesShape.AddShape(lineShape); 266 } 267 268 // not the first value 269 if (index > 0) { 270 lineShapes[index - 1].Y2 = value; 271 } 272 273 // not the last value 274 if (index > 0 && index < row.Count - 1) { 275 lineShapes[index].Y1 = value; 276 } 271 if (row.LineType == DataRowType.SingleValue) { 272 if (action == Action.Added) { 273 LineShape lineShape = new HorizontalLineShape(0, row[0], double.MaxValue, row[0], row.Color, row.Thickness, 274 row.Style); 275 lineShapes.Add(lineShape); 276 // TODO each DataRow needs its own WorldShape so Y Axes can be zoomed independently. 277 linesShape.AddShape(lineShape); 278 } 279 else { 280 // lineShapes[0].X2 = maxDataRowCount; 281 lineShapes[0].Y1 = value; 282 lineShapes[0].Y2 = value; 283 } 284 } 285 else { 286 // horizontalLineShape.YVal = maxDataValue; 287 if (index > lineShapes.Count + 1) { 288 throw new NotImplementedException(); 289 } 290 291 // new value was added 292 if (index > 0 && index == lineShapes.Count + 1) { 293 if (maxDataRowCount < row.Count) { 294 maxDataRowCount = row.Count; 295 // UpdateSingleValueRows(); 296 } 297 var lineShape = new LineShape(index - 1, row[index - 1], index, row[index], row.Color, row.Thickness, 298 row.Style); 299 lineShapes.Add(lineShape); 300 // TODO each DataRow needs its own WorldShape so Y Axes can be zoomed independently. 301 linesShape.AddShape(lineShape); 302 } 303 304 // not the first value 305 if (index > 0) { 306 lineShapes[index - 1].Y2 = value; 307 } 308 309 // not the last value 310 if (index > 0 && index < row.Count - 1) { 311 lineShapes[index].Y1 = value; 312 } 313 } 314 277 315 ZoomToFullView(); 278 279 316 canvasUI.Invalidate(); 280 317 } … … 299 336 } 300 337 301 public void OnDataRowChanged(IDataRow row) { 302 foreach (LineShape ls in rowToLineShapes[row]) { 303 ls.LSColor = row.Color; 304 ls.LSThickness = row.Thickness; 305 ls.LSDrawingStyle = row.Style; 306 } 307 canvasUI.Invalidate(); 308 } 309 338 310 339 #region Begin-/EndUpdate 311 340 312 private int beginUpdateCount = 0;341 private int beginUpdateCount; 313 342 314 343 public void BeginUpdate() { … … 349 378 Focus(); 350 379 if (e.Button == MouseButtons.Right) { 351 352 this.contextMenuStrip1.Show(PointToScreen(e.Location)); 353 380 contextMenuStrip1.Show(PointToScreen(e.Location)); 354 381 } 355 382 else { … … 383 410 384 411 private void CreateZoomListener(MouseEventArgs e) { 385 ZoomListener zoomListener = new ZoomListener(e.Location);412 var zoomListener = new ZoomListener(e.Location); 386 413 zoomListener.DrawRectangle += DrawRectangle; 387 414 zoomListener.OnMouseUp += OnZoom_MouseUp; … … 436 463 #endregion 437 464 438 private void optionsToolStripMenuItem_Click(object sender, EventArgs e) { 439 OptionsDialog optionsdlg = new OptionsDialog(this); 440 optionsdlg.ShowDialog(this); 441 } 465 442 466 } 443 467 }
Note: See TracChangeset
for help on using the changeset viewer.