Free cookie consent management tool by TermsFeed Policy Generator

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

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

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

File size: 912 bytes
Line 
1using System.Collections.Generic;
2using HeuristicLab.Visualization.Legend;
3
4namespace HeuristicLab.Visualization.Legend {
5  public class LegendShape : WorldShape {
6    private readonly IList<LegendItem> legendItems = new List<LegendItem>();
7   
8    public LegendShape() {
9      CreateLegend();
10    }
11
12    public void CreateLegend() {
13      ClearShapes();
14      double y = ClippingArea.Y2;
15      foreach (LegendItem item in legendItems) {
16        AddShape(new LineShape(10, y - 10, 30, y - 10, item.Color, item.Thickness, DrawingStyle.Solid));
17        AddShape(new TextShape(35, y, item.Label));
18        y -= 15;
19      }
20    }
21
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    }
33  }
34}
Note: See TracBrowser for help on using the repository browser.