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