Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 1233 was 1233, checked in by mstoeger, 15 years ago

General housekeeping (#498) Removed some old unused Z-Order values. Replaced some var types by concrete types. Renamed some LineShape properties. Added caching of Pens and Brushes in LineShape and RectangleShape. Put axis tick calculation algorithm into its own class.

File size: 913 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      shapes.Clear();
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.