1 | using System.Collections.Generic;
|
---|
2 | using System.Drawing;
|
---|
3 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views;
|
---|
4 | using HeuristicLab.Visualization;
|
---|
5 |
|
---|
6 | namespace 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 | }
|
---|