Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/SymbolicDataAnalysisExpressionLineageExplorerChart.cs @ 10517

Last change on this file since 10517 was 10517, checked in by bburlacu, 10 years ago

#1772: Got the lineageExplorerChart to display symbolic expression trees with the correct orientation (vertically flipped).

File size: 1.9 KB
Line 
1using System.Collections.Generic;
2using System.Drawing;
3using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views;
4using HeuristicLab.Visualization;
5
6namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
7  public partial class SymbolicDataAnalysisExpressionLineageExplorerChart : ChartControl {
8    public SymbolicDataAnalysisExpressionLineageExplorerChart() {
9      InitializeComponent();
10      if (Chart == null) { Chart = new Chart(0, 0, PreferredSize.Width, PreferredSize.Height); }
11    }
12
13    public void Clear() {
14      Chart.Group.Clear();
15    }
16
17    public void Add(IPrimitive primitive) {
18      Chart.Group.Add(primitive);
19    }
20
21    public void AddRange(IEnumerable<IPrimitive> primitives) {
22      Chart.Group.AddRange(primitives);
23    }
24
25    public void Draw(Graphics graphics) {
26      Chart.Group.Draw(graphics);
27    }
28
29    public bool UpdateEnabled {
30      get { return Chart.UpdateEnabled; }
31      set { Chart.UpdateEnabled = value; }
32    }
33
34    public void EnforceUpdate() {
35      Chart.EnforceUpdate();
36    }
37
38    public void FlipVertical() {
39      foreach (var primitive in Chart.Group.Primitives) {
40        var tile = primitive as SymbolicExpressionTreeTile;
41        if (tile != null) {
42          foreach (var p in tile.Primitives) {
43            FlipPrimitive(p);
44          }
45        } else {
46          FlipPrimitive(primitive);
47        }
48      }
49    }
50
51    public void FlipPrimitive(IPrimitive primitive) {
52      var height = pictureBox.Height;
53      var rect = primitive as RectangularPrimitiveBase;
54      var line = primitive as LinearPrimitiveBase;
55      if (rect != null) {
56        rect.SetPosition(rect.LowerLeft.X, height - rect.UpperRight.Y, rect.UpperRight.X, height - rect.LowerLeft.Y);
57      } else if (line != null) {
58        line.SetPosition(line.Start.X, height - line.Start.Y, line.End.X, height - line.End.Y);
59      }
60    }
61  }
62}
Note: See TracBrowser for help on using the repository browser.