Line | |
---|
1 | using System.Collections.Generic;
|
---|
2 | using System.Drawing;
|
---|
3 |
|
---|
4 | namespace HeuristicLab.Visualization {
|
---|
5 | public class LegendItem {
|
---|
6 | public LegendItem(string label, Color color, int thickness) {
|
---|
7 | Label = label;
|
---|
8 | Color = color;
|
---|
9 | Thickness = thickness;
|
---|
10 | }
|
---|
11 |
|
---|
12 | public string Label { get; set; }
|
---|
13 | public Color Color { get; set; }
|
---|
14 | public int Thickness { get; set; }
|
---|
15 | }
|
---|
16 |
|
---|
17 |
|
---|
18 | public class LegendShape : WorldShape {
|
---|
19 | private readonly IList<LegendItem> legendItems = new List<LegendItem>();
|
---|
20 |
|
---|
21 | public LegendShape() {
|
---|
22 | CreateLegend();
|
---|
23 | }
|
---|
24 |
|
---|
25 | public void CreateLegend() {
|
---|
26 | shapes.Clear();
|
---|
27 | double y = BoundingBox.Y2;
|
---|
28 | foreach (LegendItem item in legendItems) {
|
---|
29 | AddShape(new LineShape(10, y - 10, 30, y - 10, 0, item.Color, item.Thickness, DrawingStyle.Solid));
|
---|
30 | AddShape(new TextShape(35, y, item.Label));
|
---|
31 | y -= 15;
|
---|
32 | }
|
---|
33 | }
|
---|
34 |
|
---|
35 | public void AddLegendItem(LegendItem item) {
|
---|
36 | legendItems.Add(item);
|
---|
37 | }
|
---|
38 |
|
---|
39 | public void RemoveLegendItem(LegendItem item) {
|
---|
40 | legendItems.Remove(item);
|
---|
41 | }
|
---|
42 |
|
---|
43 | public void ClearLegendItems() {
|
---|
44 | legendItems.Clear();
|
---|
45 | }
|
---|
46 | }
|
---|
47 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.