Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/LayoutEngines/LayoutNode.cs @ 14710

Last change on this file since 14710 was 14185, checked in by swagner, 8 years ago

#2526: Updated year of copyrights in license headers

File size: 3.1 KB
RevLine 
[9970]1#region License Information
2/* HeuristicLab
[14185]3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[9970]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
[10471]22using System;
[9970]23using System.Collections.Generic;
24using System.Linq;
25
[10520]26namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
[10565]27  internal class LayoutNode<T> : object where T : class {
[10520]28    public float Width { get; set; }
29    public float Height { get; set; }
30
[10471]31    public LayoutNode<T> NextLeft {
[9970]32      get {
33        return Children == null ? Thread : Children.First();
34      }
35    }
[10471]36    public LayoutNode<T> NextRight {
[9970]37      get {
38        return Children == null ? Thread : Children.Last();
39      }
40    }
[10471]41    public LayoutNode<T> LeftSibling {
[9970]42      get {
43        if (Parent == null) return null;
44        return Number == 0 ? null : Parent.Children[Number - 1];
45      }
46    }
[10471]47    public LayoutNode<T> LeftmostSibling {
[9970]48      get {
49        if (Parent == null) return null;
50        return Number == 0 ? null : Parent.Children[0];
51      }
52    }
53
[10471]54    public LayoutNode<T> Thread { get; set; }
55    public LayoutNode<T> Ancestor { get; set; }
56    public LayoutNode<T> Parent { get; set; }
57    public List<LayoutNode<T>> Children { get; set; }
[9970]58    public float Mod { get; set; }
59    public float Prelim { get; set; }
60    public float Change { get; set; }
61    public float Shift { get; set; }
62    public int Number { get; set; }
63    public int Level { get; set; }
64    public float X { get; set; }
65    public float Y { get; set; }
66
67    public bool IsLeaf {
68      get { return Children == null || Children.Count == 0; }
69    }
70
[10471]71    private T content;
72    public T Content {
73      get { return content; }
74      set {
75        if (value == null)
76          throw new ArgumentNullException("LayoutNode: Content cannot be null.");
77        content = value;
78      }
79    }
[10520]80    /// <summary>
81    /// Translate the position of the layout node according to the given offsets
82    /// </summary>
83    /// <param name="dx"></param>
84    /// <param name="dy"></param>
85    public void Translate(float dx, float dy) {
86      X += dx;
87      Y += dy;
88    }
89
90    public void ResetCoordinates() {
91      X = 0;
92      Y = 0;
93    }
94
95    /// <summary>
96    /// Reset layout-related parameters
97    /// </summary>
98    public void Reset() {
99      Ancestor = this;
100      Thread = null;
101      Change = 0;
102      Shift = 0;
103      Prelim = 0;
104      Mod = 0;
105      ResetCoordinates();
106    }
[9970]107  }
108}
Note: See TracBrowser for help on using the repository browser.