1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Drawing;
|
---|
25 | using HeuristicLab.Visualization;
|
---|
26 |
|
---|
27 | namespace HeuristicLab.EvolutionaryTracking.Views {
|
---|
28 | public class VisualGenealogyGraphNode : Ellipse {
|
---|
29 | public GenealogyGraphNode Data { get; internal set; }
|
---|
30 | private List<VisualGenealogyGraphArc> _incomingArcs = new List<VisualGenealogyGraphArc>();
|
---|
31 | private List<VisualGenealogyGraphArc> _outgoingArgs = new List<VisualGenealogyGraphArc>();
|
---|
32 |
|
---|
33 | public List<VisualGenealogyGraphArc> IncomingArcs {
|
---|
34 | get { return _incomingArcs; }
|
---|
35 | set { _incomingArcs = value; }
|
---|
36 | }
|
---|
37 | public List<VisualGenealogyGraphArc> OutgoingArcs {
|
---|
38 | get { return _outgoingArgs; }
|
---|
39 | set { _outgoingArgs = value; }
|
---|
40 | }
|
---|
41 |
|
---|
42 | public VisualGenealogyGraphNode(IChart chart, PointD lowerLeft, PointD upperRight)
|
---|
43 | : base(chart, lowerLeft, upperRight) {
|
---|
44 | }
|
---|
45 | public VisualGenealogyGraphNode(IChart chart, double x1, double y1, double x2, double y2)
|
---|
46 | : this(chart, new PointD(x1, y1), new PointD(x2, y2)) {
|
---|
47 | }
|
---|
48 | public VisualGenealogyGraphNode(IChart chart, PointD lowerLeft, PointD upperRight, Pen pen, Brush brush)
|
---|
49 | : base(chart, lowerLeft, upperRight, pen, brush) {
|
---|
50 | }
|
---|
51 | public VisualGenealogyGraphNode(IChart chart, double x1, double y1, double x2, double y2, Pen pen, Brush brush)
|
---|
52 | : this(chart, new PointD(x1, y1), new PointD(x2, y2), pen, brush) {
|
---|
53 | }
|
---|
54 |
|
---|
55 | // compute the intersection point of an ellipse and a line passing through its center with the angular coordinate theta
|
---|
56 | public PointD CalculateIntersection(double theta) {
|
---|
57 | double sin = Math.Sin(theta);
|
---|
58 | double cos = Math.Cos(theta);
|
---|
59 | double a = Size.Width / 2;
|
---|
60 | double b = Size.Height / 2;
|
---|
61 | double r = a * b / Math.Sqrt(Math.Pow(a * sin, 2) + Math.Pow(b * cos, 2)); // radius at intersection point
|
---|
62 | double rx = r * cos; // X-component (relative to the origin/center of the ellipse)
|
---|
63 | double ry = r * sin; // Y-component (relative to the origin/center of the ellipse)
|
---|
64 | return new PointD(rx, ry);
|
---|
65 | }
|
---|
66 |
|
---|
67 | public override void SetPosition(PointD lowLeft, PointD upRight) {
|
---|
68 | base.SetPosition(lowLeft, upRight);
|
---|
69 | foreach (var a in IncomingArcs) a.UpdatePosition();
|
---|
70 | foreach (var a in OutgoingArcs) a.UpdatePosition();
|
---|
71 | }
|
---|
72 |
|
---|
73 | public PointD Center {
|
---|
74 | get { return new PointD((LowerLeft.X + UpperRight.X) / 2, (LowerLeft.Y + UpperRight.Y) / 2); }
|
---|
75 | }
|
---|
76 | }
|
---|
77 | }
|
---|