Changeset 1049
- Timestamp:
- 12/21/08 19:58:03 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization.Test/LineChartTests.cs
r1040 r1049 28 28 row2.Thickness = 4; 29 29 row3.Thickness = 5; 30 31 row1.Label = "Simon"; 32 row2.Label = "Gertschi"; 33 row3.Label = "Maxi"; 30 34 31 35 row1.Style = DrawingStyle.Solid; -
trunk/sources/HeuristicLab.Visualization/LegendShape.cs
r982 r1049 4 4 namespace HeuristicLab.Visualization { 5 5 public class LegendItem { 6 public LegendItem(string label, Color color ) {6 public LegendItem(string label, Color color, int thickness) { 7 7 Label = label; 8 8 Color = color; 9 Thickness = thickness; 9 10 } 10 11 11 12 public string Label { get; set; } 12 13 public Color Color { get; set; } 14 public int Thickness { get; set; } 13 15 } 14 16 15 17 16 public class LegendShape : IShape { 17 private readonly Color color; 18 public class LegendShape : CompositeShape { 19 private RectangleD boundingBox; 20 private Color color; 18 21 19 22 private readonly IList<LegendItem> legendItems = new List<LegendItem>(); 20 private readonly RectangleD rect;21 23 22 24 public LegendShape(double x1, double y1, double x2, double y2, double z, Color color) { 23 rect= new RectangleD(x1, y1, x2, y2);25 boundingBox = new RectangleD(x1, y1, x2, y2); 24 26 Z = z; 25 27 this.color = color; 28 CreateLegend(); 26 29 } 27 30 28 31 public double Z { get; set; } 29 32 30 #region IShape Members31 32 33 public RectangleD BoundingBox { 33 get { return rect; } 34 get { return boundingBox; } 35 set { boundingBox = value; } 34 36 } 35 37 36 public void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) { 37 int startY = 10; 38 foreach (LegendItem i in legendItems) { 39 using (Pen pen = new Pen(i.Color, 5)) { 40 graphics.DrawLine(pen, 10, startY+10, 30, startY+10); 41 } 42 using (Brush brush = new SolidBrush(Color.Black)) { 43 graphics.DrawString(i.Label, new Font("Arial", 12), brush, 35, startY); 44 } 45 startY += 15; 38 public void CreateLegend() { 39 double y = boundingBox.Y2; 40 foreach (LegendItem item in legendItems) { 41 AddShape(new LineShape(10, y - 10, 30, y - 10, 0, item.Color, item.Thickness, DrawingStyle.Solid)); 42 AddShape(new TextShape(35, y, item.Label)); 43 y -= 15; 46 44 } 47 45 } 48 49 #endregion50 46 51 47 public void AddLegendItem(LegendItem item) { -
trunk/sources/HeuristicLab.Visualization/LineChart.cs
r1045 r1049 34 34 private readonly TextShape titleShape; 35 35 private readonly LinesShape linesShape; 36 private readonly LegendShape legendShape; 36 37 37 38 private readonly XAxis xAxis; … … 62 63 root.AddShape(linesShape); 63 64 65 legendShape = new LegendShape(0,0,0,0,0,Color.Black); 66 //legendShape.AddLegendItem(new LegendItem("test", Color.Red, 5)); 67 //legendShape.AddLegendItem(new LegendItem("test1", Color.Blue, 5)); 68 //legendShape.AddLegendItem(new LegendItem("test2", Color.Pink, 5)); 69 root.AddShape(legendShape); 70 64 71 xAxis = new XAxis(dummy, dummy); 65 72 root.AddShape(xAxis); … … 67 74 titleShape = new TextShape(0, 0, "Title", 15); 68 75 root.AddShape(titleShape); 76 77 69 78 70 79 canvas.MainCanvas.WorldShape = root; … … 98 107 linesShape.BoundingBox.X2, 99 108 linesShape.BoundingBox.Y1); 109 110 legendShape.BoundingBox = new RectangleD(10, 10, 110, canvas.Height - 50); 100 111 } 101 112 … … 136 147 } 137 148 149 legendShape.AddLegendItem(new LegendItem(row.Label, row.Color, row.Thickness)); 150 legendShape.CreateLegend(); 138 151 InitLineShapes(row); 139 152 }
Note: See TracChangeset
for help on using the changeset viewer.