Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/LayoutEngines/LayoutNode.cs @ 10519

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

#2076: Removed the layout adapter and moved the functionality into the layout engine itself. Moved the layout engine to HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views. Improved layout scaling when the screen bounds are smaller than the layout bounds.

File size: 2.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 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
22using System;
23using System.Collections.Generic;
24using System.Linq;
25
26namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
27  public class LayoutNode<T> where T : class {
28    public float Width { get; set; }
29    public float Height { get; set; }
30
31    public LayoutNode<T> NextLeft {
32      get {
33        return Children == null ? Thread : Children.First();
34      }
35    }
36    public LayoutNode<T> NextRight {
37      get {
38        return Children == null ? Thread : Children.Last();
39      }
40    }
41    public LayoutNode<T> LeftSibling {
42      get {
43        if (Parent == null) return null;
44        return Number == 0 ? null : Parent.Children[Number - 1];
45      }
46    }
47    public LayoutNode<T> LeftmostSibling {
48      get {
49        if (Parent == null) return null;
50        return Number == 0 ? null : Parent.Children[0];
51      }
52    }
53
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; }
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
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    }
80  }
81}
Note: See TracBrowser for help on using the repository browser.