- Timestamp:
- 12/14/08 18:48:35 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Visualization
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization/CompositeShape.cs
r635 r987 24 24 } 25 25 26 public void ClearShapes() { 27 shapes.Clear(); 28 boundingBox = RectangleD.Empty; 29 } 30 26 31 public void AddShape(IShape shape) { 27 32 if (shapes.Count == 0) { -
trunk/sources/HeuristicLab.Visualization/LineChart.cs
r985 r987 51 51 minDataValue = Double.PositiveInfinity; 52 52 maxDataValue = Double.NegativeInfinity; 53 54 53 } 55 54 … … 88 87 maxDataRowCount = row.Count; 89 88 90 InitShapes(row); 89 InitLineShapes(row); 90 InitXAxis(); 91 } 92 93 private void InitXAxis() { 94 int numLabels = 0; 95 96 foreach (IDataRow row in model.Rows) { 97 numLabels = Math.Max(numLabels, row.Count); 98 } 99 100 xAxis.ClearLabels(); 101 102 for (int i = 0; i < numLabels; i++) { 103 xAxis.SetLabel(i, i.ToString()); 104 } 91 105 } 92 106 … … 101 115 } 102 116 103 private void InitShapes(IDataRow row) { 104 105 117 private void InitLineShapes(IDataRow row) { 106 118 List<LineShape> lineShapes = new List<LineShape>(); 107 119 if (row.Count > 0) { … … 132 144 // TODO use action parameter 133 145 private void OnRowValueChanged(IDataRow row, double value, int index, Action action) { 146 xAxis.SetLabel(index, index.ToString()); 147 134 148 List<LineShape> lineShapes = rowToLineShapes[row]; 135 149 maxDataValue = Math.Max(value, maxDataValue); … … 142 156 // new value was added 143 157 if (index > 0 && index == lineShapes.Count + 1) { 144 145 158 if (maxDataRowCount < row.Count) 146 159 maxDataRowCount = row.Count; … … 148 161 lineShapes.Add(lineShape); 149 162 // TODO each DataRow needs its own WorldShape so Y Axes can be zoomed independently. 150 canvasUI1.MainCanvas.WorldShape.AddShape(lineShape);163 root.AddShape(lineShape); 151 164 } 152 165 … … 171 184 } 172 185 173 private void OnModelChanged() {} 186 private void OnModelChanged() { 187 InitXAxis(); 188 } 174 189 175 190 #endregion -
trunk/sources/HeuristicLab.Visualization/XAxis.cs
r983 r987 1 using System.Collections.Generic; 2 using System.Drawing; 3 1 4 namespace HeuristicLab.Visualization { 5 // TODO move to own file 6 public class TextShape : IShape { 7 private readonly double x; 8 private readonly double y; 9 private string text; 10 11 private Font font = new Font("Arial", 8); 12 private Brush brush = new SolidBrush(Color.Blue); 13 14 public TextShape(double x, double y, string text) { 15 this.x = x; 16 this.y = y; 17 this.text = text; 18 } 19 20 public void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) { 21 int screenX = Transform.ToScreenX(x, viewport, clippingArea); 22 int screenY = Transform.ToScreenY(y, viewport, clippingArea); 23 24 graphics.DrawString(text, font, brush, screenX, screenY); 25 } 26 27 public RectangleD BoundingBox { 28 get { return RectangleD.Empty; } 29 } 30 31 public string Text { 32 get { return text; } 33 set { text = value; } 34 } 35 } 36 2 37 public class XAxis : CompositeShape { 38 private readonly List<TextShape> labels = new List<TextShape>(); 39 private readonly LineShape axisLine = new LineShape(0, 0, 0, 0, 0, Color.Black, 1, DrawingStyle.Solid); 3 40 41 public void ClearLabels() { 42 shapes.Clear(); 43 labels.Clear(); 44 45 shapes.Add(axisLine); 46 } 47 48 public override void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) { 49 axisLine.X1 = Transform.ToWorldX(viewport.Left, viewport, clippingArea); 50 axisLine.X2 = Transform.ToWorldX(viewport.Right, viewport, clippingArea); 51 52 base.Draw(graphics, viewport, clippingArea); 53 } 54 55 public void SetLabel(int i, string text) { 56 while (i >= labels.Count) { 57 TextShape label = new TextShape(i, 0, i.ToString()); 58 labels.Add(label); 59 AddShape(label); 60 } 61 labels[i].Text = text; 62 } 4 63 } 5 64 }
Note: See TracChangeset
for help on using the changeset viewer.