Changeset 10517 for branches/HeuristicLab.EvolutionTracking
- Timestamp:
- 02/26/14 02:19:58 (11 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeTile.cs
r10514 r10517 25 25 using HeuristicLab.Visualization; 26 26 using HeuristicLab.Visualization.Primitives; 27 using Rectangle = HeuristicLab.Visualization.Rectangle;28 27 29 28 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views { … … 56 55 LayoutEngine.CalculateLayout(); 57 56 58 var primitivesMap = new Dictionary<LayoutNode<ISymbolicExpressionTreeNode>, LabeledPrimitive>(); // both Ellipse and Rectangle are derived from the RectangularPrimitiveBase57 var primitivesMap = new Dictionary<LayoutNode<ISymbolicExpressionTreeNode>, IPrimitive>(); // both Ellipse and Rectangle are derived from the RectangularPrimitiveBase 59 58 var font = new Font(FontFamily.GenericSansSerif, 10, GraphicsUnit.Pixel); 60 59 61 60 foreach (var node in layoutNodes) { 62 LabeledPrimitive labeledPrimitive; 63 if (node.Children == null || node.Children.Count == 0) { 64 var rectangle = new Rectangle(Chart, node.X, node.Y, node.X + preferredNodeWidth, node.Y + preferredNodeHeight); 65 var textPrimitive = new TextPrimitive(Chart, rectangle.LowerLeft, rectangle.UpperRight) { 66 Font = font, 67 Text = node.Content.ToString() 68 }; 69 labeledPrimitive = new LabeledPrimitive(Chart, rectangle, textPrimitive); 61 var lowerLeft = new PointD(node.X, node.Y); 62 var upperRight = new PointD(node.X + preferredNodeWidth, node.Y + preferredNodeHeight); 63 64 RectangularPrimitiveBase rectangularPrimitive; 65 if (node.IsLeaf) { 66 rectangularPrimitive = new LabeledRectangle(Chart, lowerLeft, upperRight) { Font = font, Text = node.Content.ToString() }; 70 67 } else { 71 var ellipse = new Ellipse(Chart, node.X, node.Y, node.X + preferredNodeWidth, node.Y + preferredNodeHeight); 72 var textPrimitive = new TextPrimitive(Chart, ellipse.LowerLeft, ellipse.UpperRight) { 73 Font = font, 74 Text = node.Content.ToString() 75 }; 76 labeledPrimitive = new LabeledPrimitive(Chart, ellipse, textPrimitive); 68 rectangularPrimitive = new LabeledEllipse(Chart, lowerLeft, upperRight) { Font = font, Text = node.Content.ToString() }; 77 69 } 78 this.Add(labeledPrimitive); 79 primitivesMap.Add(node, labeledPrimitive); 70 71 this.Add(rectangularPrimitive); 72 primitivesMap.Add(node, rectangularPrimitive); 80 73 } 81 74 -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/SymbolicDataAnalysisExpressionLineageExplorerChart.cs
r10514 r10517 1 1 using System.Collections.Generic; 2 2 using System.Drawing; 3 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views; 3 4 using HeuristicLab.Visualization; 4 5 … … 7 8 public SymbolicDataAnalysisExpressionLineageExplorerChart() { 8 9 InitializeComponent(); 9 if (Chart == null) { 10 Chart = new Chart(0, 0, PreferredSize.Width, PreferredSize.Height); 11 } 10 if (Chart == null) { Chart = new Chart(0, 0, PreferredSize.Width, PreferredSize.Height); } 12 11 } 13 12 … … 27 26 Chart.Group.Draw(graphics); 28 27 } 28 29 public bool UpdateEnabled { 30 get { return Chart.UpdateEnabled; } 31 set { Chart.UpdateEnabled = value; } 32 } 33 34 public void EnforceUpdate() { 35 Chart.EnforceUpdate(); 36 } 37 38 public void FlipVertical() { 39 foreach (var primitive in Chart.Group.Primitives) { 40 var tile = primitive as SymbolicExpressionTreeTile; 41 if (tile != null) { 42 foreach (var p in tile.Primitives) { 43 FlipPrimitive(p); 44 } 45 } else { 46 FlipPrimitive(primitive); 47 } 48 } 49 } 50 51 public void FlipPrimitive(IPrimitive primitive) { 52 var height = pictureBox.Height; 53 var rect = primitive as RectangularPrimitiveBase; 54 var line = primitive as LinearPrimitiveBase; 55 if (rect != null) { 56 rect.SetPosition(rect.LowerLeft.X, height - rect.UpperRight.Y, rect.UpperRight.X, height - rect.LowerLeft.Y); 57 } else if (line != null) { 58 line.SetPosition(line.Start.X, height - line.Start.Y, line.End.X, height - line.End.Y); 59 } 60 } 29 61 } 30 62 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/SymbolicDataAnalysisExpressionLineageExplorerView.Designer.cs
r10514 r10517 25 25 private void InitializeComponent() { 26 26 this.treeView = new System.Windows.Forms.TreeView(); 27 this. symbolicDataAnalysisExpressionLineageExplorerChart = new HeuristicLab.Problems.DataAnalysis.Symbolic.Views.SymbolicDataAnalysisExpressionLineageExplorerChart();27 this.lineageExplorerChart = new HeuristicLab.Problems.DataAnalysis.Symbolic.Views.SymbolicDataAnalysisExpressionLineageExplorerChart(); 28 28 this.SuspendLayout(); 29 29 // … … 38 38 this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterSelect); 39 39 // 40 // symbolicDataAnalysisExpressionLineageExplorerChart40 // lineageExplorerChart 41 41 // 42 this. symbolicDataAnalysisExpressionLineageExplorerChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)42 this.lineageExplorerChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 43 43 | System.Windows.Forms.AnchorStyles.Left) 44 44 | System.Windows.Forms.AnchorStyles.Right))); 45 this. symbolicDataAnalysisExpressionLineageExplorerChart.AutoSize = true;46 this. symbolicDataAnalysisExpressionLineageExplorerChart.BackColor = System.Drawing.SystemColors.Control;47 this. symbolicDataAnalysisExpressionLineageExplorerChart.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;48 this. symbolicDataAnalysisExpressionLineageExplorerChart.Chart = null;49 this. symbolicDataAnalysisExpressionLineageExplorerChart.Location = new System.Drawing.Point(176, 3);50 this. symbolicDataAnalysisExpressionLineageExplorerChart.Name = "symbolicDataAnalysisExpressionLineageExplorerChart";51 this. symbolicDataAnalysisExpressionLineageExplorerChart.ScaleOnResize = true;52 this. symbolicDataAnalysisExpressionLineageExplorerChart.Size = new System.Drawing.Size(657, 593);53 this. symbolicDataAnalysisExpressionLineageExplorerChart.TabIndex = 1;45 this.lineageExplorerChart.AutoSize = true; 46 this.lineageExplorerChart.BackColor = System.Drawing.SystemColors.Control; 47 this.lineageExplorerChart.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 48 this.lineageExplorerChart.Chart = null; 49 this.lineageExplorerChart.Location = new System.Drawing.Point(176, 3); 50 this.lineageExplorerChart.Name = "lineageExplorerChart"; 51 this.lineageExplorerChart.ScaleOnResize = true; 52 this.lineageExplorerChart.Size = new System.Drawing.Size(657, 593); 53 this.lineageExplorerChart.TabIndex = 1; 54 54 // 55 55 // SymbolicDataAnalysisExpressionLineageExplorerView … … 57 57 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 58 58 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 59 this.Controls.Add(this. symbolicDataAnalysisExpressionLineageExplorerChart);59 this.Controls.Add(this.lineageExplorerChart); 60 60 this.Controls.Add(this.treeView); 61 61 this.DoubleBuffered = true; … … 70 70 71 71 private System.Windows.Forms.TreeView treeView; 72 private SymbolicDataAnalysisExpressionLineageExplorerChart symbolicDataAnalysisExpressionLineageExplorerChart;72 private SymbolicDataAnalysisExpressionLineageExplorerChart lineageExplorerChart; 73 73 } 74 74 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/SymbolicDataAnalysisExpressionLineageExplorerView.cs
r10514 r10517 1 1 using System.Collections.Generic; 2 using System.Drawing.Text;3 2 using System.Globalization; 4 3 using System.Linq; … … 15 14 [Content(typeof(IGenealogyGraph), false)] 16 15 public partial class SymbolicDataAnalysisExpressionLineageExplorerView : AsynchronousContentView { 17 private readonly ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode> SymbolicExpressionTreeNodeLayoutEngine;18 private readonly SymbolicExpressionTreeLayoutAdapter SymbolicExpressionTreeLayoutAdapter;16 private readonly ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode> symbolicExpressionTreeNodeLayoutEngine; 17 private readonly SymbolicExpressionTreeLayoutAdapter symbolicExpressionTreeLayoutAdapter; 19 18 20 private readonly Dictionary<TreeNode, ISymbolicExpressionTree> TreeMap;19 private readonly Dictionary<TreeNode, ISymbolicExpressionTree> treeMap; 21 20 22 21 private const int MinHorizontalSpacing = 50; … … 32 31 public SymbolicDataAnalysisExpressionLineageExplorerView() { 33 32 InitializeComponent(); 34 SymbolicExpressionTreeNodeLayoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode> {33 symbolicExpressionTreeNodeLayoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode> { 35 34 MinHorizontalSpacing = MinHorizontalSpacing + PreferredNodeWidth, 36 35 MinVerticalSpacing = MinVerticalSpacing + PreferredNodeHeight 37 36 }; 38 SymbolicExpressionTreeLayoutAdapter = new SymbolicExpressionTreeLayoutAdapter();39 TreeMap = new Dictionary<TreeNode, ISymbolicExpressionTree>();40 double width = symbolicDataAnalysisExpressionLineageExplorerChart.PreferredSize.Width;41 double height = symbolicDataAnalysisExpressionLineageExplorerChart.PreferredSize.Height;42 if ( symbolicDataAnalysisExpressionLineageExplorerChart.Chart == null) {43 symbolicDataAnalysisExpressionLineageExplorerChart.Chart = new Chart(0, 0, width, height);37 symbolicExpressionTreeLayoutAdapter = new SymbolicExpressionTreeLayoutAdapter(); 38 treeMap = new Dictionary<TreeNode, ISymbolicExpressionTree>(); 39 double width = lineageExplorerChart.PreferredSize.Width; 40 double height = lineageExplorerChart.PreferredSize.Height; 41 if (lineageExplorerChart.Chart == null) { 42 lineageExplorerChart.Chart = new Chart(0, 0, width, height); 44 43 } 45 44 } … … 60 59 private void updateTreeView() { 61 60 var lastGen = Content.Ranks.OrderBy(x => x.Key).Last().Value.ToList(); 62 TreeMap.Clear();63 symbolicDataAnalysisExpressionLineageExplorerChart.Clear();61 treeMap.Clear(); 62 lineageExplorerChart.Clear(); 64 63 foreach (var g in lastGen) { 65 64 var treeNode = new TreeNode(g.Quality.ToString(CultureInfo.InvariantCulture)); 66 65 treeView.Nodes.Add(treeNode); 67 TreeMap.Add(treeNode, (ISymbolicExpressionTree)g.Content);66 treeMap.Add(treeNode, (ISymbolicExpressionTree)g.Content); 68 67 } 69 68 } 70 69 71 70 private void treeView_AfterSelect(object sender, TreeViewEventArgs e) { 72 symbolicDataAnalysisExpressionLineageExplorerChart.Clear();71 lineageExplorerChart.Clear(); 73 72 var selectedNode = treeView.SelectedNode; 74 var symbolicExpressionTree = TreeMap[selectedNode]; 75 var tile = new SymbolicExpressionTreeTile(this.symbolicDataAnalysisExpressionLineageExplorerChart.Chart) { 76 LayoutAdapter = SymbolicExpressionTreeLayoutAdapter, 77 LayoutEngine = SymbolicExpressionTreeNodeLayoutEngine, 73 var symbolicExpressionTree = treeMap[selectedNode]; 74 var chart = lineageExplorerChart.Chart; 75 var tile = new SymbolicExpressionTreeTile(chart) { 76 LayoutAdapter = symbolicExpressionTreeLayoutAdapter, 77 LayoutEngine = symbolicExpressionTreeNodeLayoutEngine, 78 78 PreferredNodeWidth = PreferredNodeWidth, 79 PreferredNodeHeight = PreferredNodeHeight 79 PreferredNodeHeight = PreferredNodeHeight, 80 SymbolicExpressionTree = symbolicExpressionTree 80 81 }; 81 tile.SymbolicExpressionTree = symbolicExpressionTree; 82 symbolicDataAnalysisExpressionLineageExplorerChart.Add(tile); 83 84 // graphics.TranslateTransform(0, symbolicDataAnalysisExpressionLineageExplorerChart.Height); 85 // graphics.ScaleTransform(1f, -1f); // flip vertically (because the visualization plugin is upside-down 86 // graphics.RotateTransform(180F); 87 var graphics = symbolicDataAnalysisExpressionLineageExplorerChart.CreateGraphics(); 88 graphics.ScaleTransform(1f, -1f); // flip vertically (because the visualization plugin is upside-down 89 graphics.TextRenderingHint = TextRenderingHint.AntiAlias; 90 symbolicDataAnalysisExpressionLineageExplorerChart.Draw(graphics); 82 lineageExplorerChart.UpdateEnabled = false; 83 lineageExplorerChart.Add(tile); 84 lineageExplorerChart.FlipVertical(); 85 lineageExplorerChart.UpdateEnabled = true; 86 lineageExplorerChart.EnforceUpdate(); 91 87 } 92 88 }
Note: See TracChangeset
for help on using the changeset viewer.