Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/SymbolicExpressionChartControl.cs @ 10746

Last change on this file since 10746 was 10746, checked in by bburlacu, 8 years ago

#1772: Small improvements to FragmentGraphView, moved tracking classes to separate folder.

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