Changeset 5513 for branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs
- Timestamp:
- 02/18/11 10:55:20 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs
r5473 r5513 24 24 using System.Drawing; 25 25 using System.Drawing.Imaging; 26 using System.Linq; 26 27 using System.Windows.Forms; 27 28 … … 30 31 private Image image; 31 32 private StringFormat stringFormat; 32 private Dictionary< SymbolicExpressionTreeNode, VisualSymbolicExpressionTreeNode> visualTreeNodes;33 private Dictionary<ISymbolicExpressionTreeNode, VisualSymbolicExpressionTreeNode> visualTreeNodes; 33 34 34 35 public SymbolicExpressionTreeChart() { … … 44 45 } 45 46 46 public SymbolicExpressionTreeChart( SymbolicExpressionTree tree)47 public SymbolicExpressionTreeChart(ISymbolicExpressionTree tree) 47 48 : this() { 48 49 this.Tree = tree; … … 85 86 } 86 87 87 private SymbolicExpressionTree tree;88 public SymbolicExpressionTree Tree {88 private ISymbolicExpressionTree tree; 89 public ISymbolicExpressionTree Tree { 89 90 get { return this.tree; } 90 91 set { 91 92 tree = value; 92 visualTreeNodes = new Dictionary< SymbolicExpressionTreeNode, VisualSymbolicExpressionTreeNode>();93 visualTreeNodes = new Dictionary<ISymbolicExpressionTreeNode, VisualSymbolicExpressionTreeNode>(); 93 94 if (tree != null) { 94 95 foreach (SymbolicExpressionTreeNode node in tree.IterateNodesPrefix()) … … 129 130 } 130 131 131 public VisualSymbolicExpressionTreeNode GetVisualSymbolicExpressionTreeNode( SymbolicExpressionTreeNode symbolicExpressionTreeNode) {132 public VisualSymbolicExpressionTreeNode GetVisualSymbolicExpressionTreeNode(ISymbolicExpressionTreeNode symbolicExpressionTreeNode) { 132 133 if (visualTreeNodes.ContainsKey(symbolicExpressionTreeNode)) 133 134 return visualTreeNodes[symbolicExpressionTreeNode]; … … 207 208 208 209 #region methods for painting the symbolic expression tree 209 private void DrawFunctionTree( SymbolicExpressionTree tree, Graphics graphics, int x, int y, int width, int height) {210 private void DrawFunctionTree(ISymbolicExpressionTree tree, Graphics graphics, int x, int y, int width, int height) { 210 211 DrawFunctionTree(tree.Root, graphics, x, y, width, height, Point.Empty); 211 212 } … … 220 221 /// <param name="width">width of drawing area</param> 221 222 /// <param name="height">height of drawing area</param> 222 private void DrawFunctionTree( SymbolicExpressionTreeNode node, Graphics graphics, int x, int y, int width, int height, Point connectionPoint) {223 private void DrawFunctionTree(ISymbolicExpressionTreeNode node, Graphics graphics, int x, int y, int width, int height, Point connectionPoint) { 223 224 VisualSymbolicExpressionTreeNode visualTreeNode = visualTreeNodes[node]; 224 225 float center_x = x + width / 2; … … 262 263 263 264 //draw terminal node 264 if (node.SubTrees.Count == 0) {265 if (node.SubTrees.Count() == 0) { 265 266 graphics.FillRectangle(nodeFillBrush, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height); 266 267 graphics.DrawRectangle(nodeLinePen, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height); … … 280 281 //calculate areas for the subtrees according to their tree size and call drawFunctionTree 281 282 Point connectFrom = new Point(visualTreeNode.X + visualTreeNode.Width / 2, visualTreeNode.Y + visualTreeNode.Height); 282 int[] xBoundaries = new int[node.SubTrees.Count + 1];283 int[] xBoundaries = new int[node.SubTrees.Count() + 1]; 283 284 xBoundaries[0] = x; 284 for (int i = 0; i < node.SubTrees.Count ; i++) {285 xBoundaries[i + 1] = (int)(xBoundaries[i] + (width * (double)node.SubTrees [i].GetSize()) / (node.GetSize() - 1));286 DrawFunctionTree(node.SubTrees [i], graphics, xBoundaries[i], y + height,285 for (int i = 0; i < node.SubTrees.Count(); i++) { 286 xBoundaries[i + 1] = (int)(xBoundaries[i] + (width * (double)node.SubTrees.ElementAt(i).GetSize()) / (node.GetSize() - 1)); 287 DrawFunctionTree(node.SubTrees.ElementAt(i), graphics, xBoundaries[i], y + height, 287 288 xBoundaries[i + 1] - xBoundaries[i], height, connectFrom); 288 289 }
Note: See TracChangeset
for help on using the changeset viewer.