Changeset 1242
- Timestamp:
- 03/03/09 20:10:48 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Visualization
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization/HorizontalLineShape.cs
r1240 r1242 2 2 3 3 namespace HeuristicLab.Visualization { 4 public class MinMaxLineShape : WorldShape { 5 private readonly LineShape minLineShape; 6 private readonly LineShape maxLineShape; 7 4 public class HorizontalLineShape : LineShape { 8 5 /// <summary> 9 /// Initializes the HorizontalLineShape.6 /// Initializes the LineShape. 10 7 /// </summary> 8 /// <param name="x1">x coordinate of left lineEndPoind</param> 9 /// <param name="y1">y coordinate of left lineEndPoind</param> 10 /// <param name="x2">x coordinate of right lineEndPoind</param> 11 /// <param name="y2">y coordinate of right lineEndPoind</param> 11 12 /// <param name="color">color for the LineShape</param> 12 /// <param name="yMin">y value for lower line</param> 13 /// <param name="yMax">y value for upper line</param> 14 /// <param name="thickness">line thickness</param> 15 /// <param name="style">line style</param> 16 public MinMaxLineShape(double yMin, double yMax, Color color, int thickness, DrawingStyle style) { 17 minLineShape = new LineShape(0, yMin, 1, yMin, color, thickness, style); 18 maxLineShape = new LineShape(0, yMax, 1, yMax, color, thickness, style); 19 AddShape(minLineShape); 20 AddShape(maxLineShape); 21 } 13 /// <param name="thickness">tickness of the line in pixels</param> 14 /// <param name="drawingStyle">drawing style of the line (solid, dashed, dotted,...)</param> 15 public HorizontalLineShape(double x1, double y1, double x2, double y2, Color color, int thickness, 16 DrawingStyle drawingStyle) : base(x1, y1, x2, y2, color, thickness, drawingStyle) {} 22 17 23 18 public override void Draw(Graphics graphics) { 24 minLineShape.X1 = ClippingArea.X1; 25 minLineShape.X2 = ClippingArea.X2; 26 maxLineShape.X1 = ClippingArea.X1; 27 maxLineShape.X2 = ClippingArea.X2; 19 X1 = Parent.ClippingArea.X1; 20 X2 = Parent.ClippingArea.X2; 21 Y2 = Y1; 28 22 base.Draw(graphics); 29 }30 31 32 public double YMin {33 set {34 minLineShape.Y1 = value;35 minLineShape.Y2 = value;36 }37 }38 39 public double YMax {40 set {41 maxLineShape.Y1 = value;42 maxLineShape.Y2 = value;43 }44 23 } 45 24 } -
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 } -
trunk/sources/HeuristicLab.Visualization/LineShape.cs
r1240 r1242 32 32 public RectangleD BoundingBox { 33 33 get { return boundingBox; } 34 set { boundingBox = value; } 34 35 } 35 36 … … 71 72 /// </summary> 72 73 /// <param name="graphics">graphics handle to draw to</param> 73 public v oid Draw(Graphics graphics) {74 public virtual void Draw(Graphics graphics) { 74 75 Rectangle screenRect = Transform.ToScreen(boundingBox, Parent.Viewport, Parent.ClippingArea); 75 76 -
trunk/sources/HeuristicLab.Visualization/Options/OptionsDialog.cs
r1237 r1242 5 5 namespace HeuristicLab.Visualization.Options { 6 6 public partial class OptionsDialog : Form { 7 private readonly LineChart lc;7 private readonly IChartDataRowsModel model; 8 8 9 public OptionsDialog( LineChart lc) {9 public OptionsDialog(IChartDataRowsModel model) { 10 10 InitializeComponent(); 11 this. lc = lc;11 this.model = model; 12 12 } 13 13 … … 27 27 28 28 private void OptionsDialog_Load(object sender, EventArgs e) { 29 if ( lc.GetRows().Count != 0) {30 LineSelectCB.DataSource = lc.GetRows();29 if (model.Rows.Count != 0) { 30 LineSelectCB.DataSource = model.Rows; 31 31 LineSelectCB.DisplayMember = "Label"; 32 32
Note: See TracChangeset
for help on using the changeset viewer.