Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Layout/LayoutBase.cs @ 4068

Last change on this file since 4068 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

File size: 2.9 KB
Line 
1using System;
2using System.Drawing;
3using Netron.Diagramming.Core.Analysis;
4namespace Netron.Diagramming.Core {
5  /// <summary>
6  /// Base class for graph layout
7  /// </summary>
8  abstract class LayoutBase : ActionBase, ILayout {
9    #region Fields
10    private IGraph graph;
11
12    private string mName;
13    private Rectangle mBounds;
14    private PointF mCenter;
15    private const int defaultSpan = 400;
16    private IController mController = null;
17    #endregion
18
19    #region Properties
20
21    /// <summary>
22    /// Gets the nodes of the graph. This is another casting of the shapes collection of the model.
23    /// </summary>
24    /// <value>The nodes.</value>
25    public CollectionBase<INode> Nodes {
26      get { return graph.Nodes; }
27    }
28
29    /// <summary>
30    /// Gets the edges of the graph. This is just another casting of the connection collection of the model.
31    /// </summary>
32    /// <value>The edges.</value>
33    public CollectionBase<IEdge> Edges {
34      get { return graph.Edges; }
35    }
36
37    public IController Controller {
38      get { return mController; }
39    }
40
41    protected int DefaultRunSpan {
42      get { return defaultSpan; }
43    }
44
45    /// <summary>
46    /// Gets or sets the center of the layout. This can be the arithmetic middle
47    /// of the bounding area or can be set independently.
48    /// </summary>
49    public PointF Center {
50      get { return mCenter; }
51      set { mCenter = value; }
52    }
53
54    public IGraph Graph {
55      get { return graph; }
56      set { graph = value; }
57    }
58    /// <summary>
59    /// Gets or sets the bounds of the layout surface.
60    /// </summary>
61    /// <value>The bounds.</value>
62    public Rectangle Bounds {
63      get { return mBounds; }
64      set { mBounds = value; }
65
66    }
67    public string LayoutName {
68      get { return mName; }
69    }
70    #endregion
71
72    #region Constructor
73    /// <summary>
74    /// Initializes a new instance of the <see cref="T:LayoutBase"/> class.
75    /// </summary>
76    /// <param name="name">The name.</param>
77    /// <param name="controller">The controller.</param>
78    protected LayoutBase(string name, IController controller)
79      : base(name) {
80      mName = name;
81      mController = controller;
82    }
83
84    #endregion
85
86    #region Methods
87    protected void setX(INode item, INode referrer, double x) {
88
89      //float sx = item.Rectangle.X;
90      //if(float.IsNaN(sx))
91      //    sx = (referrer != null ? referrer.Rectangle.X : x);
92
93      item.MoveBy(new Point(Convert.ToInt32(x - item.Rectangle.X), 0));
94      //Trace.WriteLine("setX(" + x + ",0)");
95
96    }
97    protected void setY(INode item, INode referrer, double y) {
98
99      //float sx = item.Rectangle.X;
100      //if(float.IsNaN(sx))
101      //    sx = (referrer != null ? referrer.Rectangle.X : x);
102
103      item.MoveBy(new Point(0, Convert.ToInt32(y - item.Rectangle.Y)));
104      //Trace.WriteLine("setY(0," + y +")");
105    }
106    #endregion
107
108
109
110  }
111
112}
Note: See TracBrowser for help on using the repository browser.