Changeset 1049 for trunk/sources/HeuristicLab.Visualization/LegendShape.cs
- Timestamp:
- 12/21/08 19:58:03 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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) {
Note: See TracChangeset
for help on using the changeset viewer.