Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization/Legend/LegendShape.cs @ 1270

Last change on this file since 1270 was 1240, checked in by mstoeger, 16 years ago

Transformations on shapes are possible outside of the Draw method. (#424)

File size: 912 bytes
RevLine 
[873]1using System.Collections.Generic;
[1233]2using HeuristicLab.Visualization.Legend;
[866]3
[1233]4namespace HeuristicLab.Visualization.Legend {
[1195]5  public class LegendShape : WorldShape {
[873]6    private readonly IList<LegendItem> legendItems = new List<LegendItem>();
[1195]7   
8    public LegendShape() {
[1049]9      CreateLegend();
[866]10    }
11
[1049]12    public void CreateLegend() {
[1240]13      ClearShapes();
[1232]14      double y = ClippingArea.Y2;
[1049]15      foreach (LegendItem item in legendItems) {
[1233]16        AddShape(new LineShape(10, y - 10, 30, y - 10, item.Color, item.Thickness, DrawingStyle.Solid));
[1049]17        AddShape(new TextShape(35, y, item.Label));
18        y -= 15;
[866]19      }
20    }
21
[873]22    public void AddLegendItem(LegendItem item) {
23      legendItems.Add(item);
24    }
25
26    public void RemoveLegendItem(LegendItem item) {
27      legendItems.Remove(item);
28    }
29
30    public void ClearLegendItems() {
31      legendItems.Clear();
32    }
[866]33  }
34}
Note: See TracBrowser for help on using the repository browser.