Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/18/14 12:35:00 (10 years ago)
Author:
ascheibe
Message:

reverted last commit

Location:
branches/HiveStatistics/sources
Files:
4 deleted
21 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/HiveStatistics/sources

  • branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views

  • branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/GraphicalSymbolicExpressionTreeView.Designer.cs

    r11202 r11203  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    1919 */
    2020#endregion
    21 
    22 using System.Drawing;
    2321
    2422namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
     
    6159      this.symbolicExpressionTreeChart.Spacing = 5;
    6260      this.symbolicExpressionTreeChart.TabIndex = 0;
    63       this.symbolicExpressionTreeChart.TextFont = new System.Drawing.Font(FontFamily.GenericSerif, 8F);
     61      this.symbolicExpressionTreeChart.TextFont = new System.Drawing.Font("Times New Roman", 6F);
    6462      //
    6563      // FunctionTreeView
  • branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/GraphicalSymbolicExpressionTreeView.cs

    r11202 r11203  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.4.csproj

    r11202 r11203  
    110110  </ItemGroup>
    111111  <ItemGroup>
    112     <Compile Include="Formatters\SymbolicExpressionTreeLatexFormatter.cs" />
    113     <Compile Include="LayoutEngines\BoxesLayoutEngine.cs" />
    114     <Compile Include="LayoutEngines\ILayoutEngine.cs" />
    115     <Compile Include="LayoutEngines\LayoutNode.cs" />
    116     <Compile Include="LayoutEngines\ReingoldTilfordLayoutEngine.cs" />
    117112    <Compile Include="Plugin.cs" />
    118113    <Compile Include="SymbolicExpressionGrammarAllowedChildSymbolsControl.cs">
     
    165160      <DependentUpon>SymbolicExpressionView.cs</DependentUpon>
    166161    </Compile>
    167     <Compile Include="VisualTreeNode.cs" />
    168     <Compile Include="VisualTreeNodeConnection.cs" />
     162    <Compile Include="VisualSymbolicExpressionTreeNode.cs" />
     163    <Compile Include="VisualSymbolicExpressionTreeNodeConnection.cs" />
    169164  </ItemGroup>
    170165  <ItemGroup>
     
    281276  -->
    282277  <PropertyGroup>
    283     <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
     278   <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
    284279set ProjectDir=$(ProjectDir)
    285280set SolutionDir=$(SolutionDir)
     
    288283call PreBuildEvent.cmd
    289284</PreBuildEvent>
    290     <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
     285<PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
    291286export ProjectDir=$(ProjectDir)
    292287export SolutionDir=$(SolutionDir)
  • branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/Plugin.cs.frame

    r11202 r11203  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2626
    2727namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
    28   [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views","Provides views for the symbolic expression tree encoding.", "3.4.6.$WCREV$")]
     28  [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views","Provides views for the symbolic expression tree encoding.", "3.4.3.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.4.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Collections", "3.3")]
  • branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/Properties/AssemblyInfo.cs.frame

    r11202 r11203  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3232[assembly: AssemblyCompany("")]
    3333[assembly: AssemblyProduct("HeuristicLab")]
    34 [assembly: AssemblyCopyright("(c) 2002-2014 HEAL")]
     34[assembly: AssemblyCopyright("(c) 2002-2012 HEAL")]
    3535[assembly: AssemblyTrademark("")]
    3636[assembly: AssemblyCulture("")]
     
    4545
    4646[assembly: AssemblyVersion("3.4.0.0")]
    47 [assembly: AssemblyFileVersion("3.4.6.$WCREV$")]
     47[assembly: AssemblyFileVersion("3.4.3.$WCREV$")]
  • branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolView.Designer.cs

    r11202 r11203  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolView.cs

    r11202 r11203  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarAllowedChildSymbolsControl.Designer.cs

    r11202 r11203  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarAllowedChildSymbolsControl.cs

    r11202 r11203  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2929using HeuristicLab.PluginInfrastructure;
    3030
    31 using VisualSymbolicExpressionTreeNode = HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.VisualTreeNode<HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ISymbolicExpressionTreeNode>;
    32 
    3331namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
    3432  public sealed partial class SymbolicExpressionGrammarAllowedChildSymbolsControl : UserControl {
     
    105103
    106104      var tree = new SymbolicExpressionTree(new SymbolicExpressionTreeNode(Symbol));
     105      symbolicExpressionTreeChart.SuspendRepaint = true;
    107106      if (Grammar.GetMaximumSubtreeCount(Symbol) > 0) {
    108107        for (int i = 0; i < Grammar.GetMaximumSubtreeCount(Symbol); i++) {
     
    117116      }
    118117      symbolicExpressionTreeChart.Tree = tree;
    119       symbolicExpressionTreeChart.SuspendRepaint = true;
     118
    120119      foreach (var subtreeNode in tree.Root.Subtrees) {
    121120        foreach (var allowedChildNode in subtreeNode.Subtrees) {
     
    143142        }
    144143      }
     144
    145145      symbolicExpressionTreeChart.SuspendRepaint = false;
    146146      UpdateSelectedSymbolicExpressionTreeNodes();
     
    153153        else visualNode.FillColor = Color.LightSteelBlue;
    154154      }
    155       symbolicExpressionTreeChart.RepaintNodes();
     155      symbolicExpressionTreeChart.Repaint();
    156156    }
    157157
     
    162162
    163163      VisualSymbolicExpressionTreeNode clickedNode = (VisualSymbolicExpressionTreeNode)sender;
    164       var selectedNode = clickedNode.Content;
     164      var selectedNode = clickedNode.SymbolicExpressionTreeNode;
    165165      if (selectedNode.SubtreeCount == 0) {
    166166        if (!selectedSymbolicExpressionTreeNodes.Contains(selectedNode))
     
    207207        var visualNode = symbolicExpressionTreeChart.FindVisualSymbolicExpressionTreeNodeAt(coordinates.X, coordinates.Y);
    208208        if (visualNode != null) {
    209           var node = visualNode.Content;
     209          var node = visualNode.SymbolicExpressionTreeNode;
    210210          var root = symbolicExpressionTreeChart.Tree.Root;
    211211          if (node == root || node.Parent == root) e.Effect = DragDropEffects.Copy;
     
    223223      var symbols = data as IEnumerable<ISymbol>;
    224224
    225       if (node.Content == root) {
     225      if (node.SymbolicExpressionTreeNode == root) {
    226226        if (symbol != null)
    227227          Grammar.AddAllowedChildSymbol(root.Symbol, symbol);
     
    229229          foreach (var s in symbols) Grammar.AddAllowedChildSymbol(root.Symbol, s);
    230230      } else {
    231         int argumentIndex = root.IndexOfSubtree(node.Content);
     231        int argumentIndex = root.IndexOfSubtree(node.SymbolicExpressionTreeNode);
    232232        if (symbol != null)
    233233          Grammar.AddAllowedChildSymbol(root.Symbol, symbol, argumentIndex);
  • branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.Designer.cs

    r11202 r11203  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.cs

    r11202 r11203  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    8484          if (node.Checked) node.Expand();
    8585
    86         //mkommend: scrolls to the top node
    87         symbolsTreeView.Nodes[0].EnsureVisible();
    88 
    8986        allowedChildSymbolsControl.Grammar = Content;
    9087        allowedChildSymbolsControl.Symbol = null;
     
    139136      var topLevelSymbols = Content.Symbols.Where(s => !groupSymbols.Any(g => g.Symbols.Contains(s)));
    140137      UpdateChildTreeNodes(symbolsTreeView.Nodes, topLevelSymbols);
     138
    141139      RebuildImageList();
    142140    }
  • branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarSampleExpressionTreeView.Designer.cs

    r11202 r11203  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarSampleExpressionTreeView.cs

    r11202 r11203  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    4242        treeCreatorComboBox.Items.Add(treeCreator);
    4343      }
    44       treeCreatorComboBox.SelectedItem = treeCreatorComboBox.Items.OfType<ProbabilisticTreeCreator>().First();
     44      treeCreatorComboBox.SelectedIndex = 0;
    4545    }
    4646
  • branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarView.Designer.cs

    r11202 r11203  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarView.cs

    r11202 r11203  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.Designer.cs

    r11202 r11203  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    4949      this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
    5050      this.saveImageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    51       this.exportPgfLaTeXToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    52       this.layoutEngineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    53       this.reingoldTilfordToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    54       this.boxesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    5551      this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
    5652      this.contextMenuStrip.SuspendLayout();
     
    6056      //
    6157      this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
    62             this.saveImageToolStripMenuItem,
    63             this.exportPgfLaTeXToolStripMenuItem,
    64             this.layoutEngineToolStripMenuItem});
     58            this.saveImageToolStripMenuItem});
    6559      this.contextMenuStrip.Name = "contextMenuStrip";
    66       this.contextMenuStrip.Size = new System.Drawing.Size(166, 70);
     60      this.contextMenuStrip.Size = new System.Drawing.Size(135, 26);
    6761      //
    6862      // saveImageToolStripMenuItem
    6963      //
    7064      this.saveImageToolStripMenuItem.Name = "saveImageToolStripMenuItem";
    71       this.saveImageToolStripMenuItem.Size = new System.Drawing.Size(165, 22);
     65      this.saveImageToolStripMenuItem.Size = new System.Drawing.Size(134, 22);
    7266      this.saveImageToolStripMenuItem.Text = "Save Image";
    7367      this.saveImageToolStripMenuItem.Click += new System.EventHandler(this.saveImageToolStripMenuItem_Click);
    74       //
    75       // exportPgfLaTeXToolStripMenuItem
    76       //
    77       this.exportPgfLaTeXToolStripMenuItem.Name = "exportPgfLaTeXToolStripMenuItem";
    78       this.exportPgfLaTeXToolStripMenuItem.Size = new System.Drawing.Size(165, 22);
    79       this.exportPgfLaTeXToolStripMenuItem.Text = "Export Pgf/LaTeX";
    80       this.exportPgfLaTeXToolStripMenuItem.Click += new System.EventHandler(this.exportLatexToolStripMenuItem_Click);
    81       //
    82       // layoutEngineToolStripMenuItem
    83       //
    84       this.layoutEngineToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
    85             this.reingoldTilfordToolStripMenuItem,
    86             this.boxesToolStripMenuItem});
    87       this.layoutEngineToolStripMenuItem.Name = "layoutEngineToolStripMenuItem";
    88       this.layoutEngineToolStripMenuItem.Size = new System.Drawing.Size(165, 22);
    89       this.layoutEngineToolStripMenuItem.Text = "Layout Engine:";
    90       //
    91       // reingoldTilfordToolStripMenuItem
    92       //
    93       this.reingoldTilfordToolStripMenuItem.Name = "reingoldTilfordToolStripMenuItem";
    94       this.reingoldTilfordToolStripMenuItem.Size = new System.Drawing.Size(161, 22);
    95       this.reingoldTilfordToolStripMenuItem.Text = "Reingold-Tilford";
    96       this.reingoldTilfordToolStripMenuItem.Click += new System.EventHandler(this.reingoldTilfordToolStripMenuItem_Click);
    97       //
    98       // boxesToolStripMenuItem
    99       //
    100       this.boxesToolStripMenuItem.Name = "boxesToolStripMenuItem";
    101       this.boxesToolStripMenuItem.Size = new System.Drawing.Size(161, 22);
    102       this.boxesToolStripMenuItem.Text = "Boxes";
    103       this.boxesToolStripMenuItem.Click += new System.EventHandler(this.boxesToolStripMenuItem_Click);
    10468      //
    10569      // saveFileDialog
    10670      //
    10771      this.saveFileDialog.Filter = "Bitmap (*.bmp)|*.bmp|EMF (*.emf)|*.emf";
    108       //
     72      this.saveFileDialog.FilterIndex = 1;
    10973      // SymbolicExpressionTreeChart
    11074      //
     75      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    11176      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    11277      this.ContextMenuStrip = this.contextMenuStrip;
    113       this.DoubleBuffered = true;
    11478      this.Name = "SymbolicExpressionTreeChart";
    11579      this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.SymbolicExpressionTreeChart_MouseClick);
     
    12993    protected System.Windows.Forms.ToolStripMenuItem saveImageToolStripMenuItem;
    13094    protected System.Windows.Forms.SaveFileDialog saveFileDialog;
    131     private System.Windows.Forms.ToolStripMenuItem exportPgfLaTeXToolStripMenuItem;
    132     private System.Windows.Forms.ToolStripMenuItem layoutEngineToolStripMenuItem;
    133     private System.Windows.Forms.ToolStripMenuItem reingoldTilfordToolStripMenuItem;
    134     private System.Windows.Forms.ToolStripMenuItem boxesToolStripMenuItem;
    13595  }
    13696}
  • branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs

    r11202 r11203  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2424using System.Drawing;
    2525using System.Drawing.Imaging;
    26 using System.IO;
    27 using System.Linq;
    2826using System.Windows.Forms;
    29 
    3027
    3128namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
    3229  public partial class SymbolicExpressionTreeChart : UserControl {
    3330    private Image image;
    34     private readonly StringFormat stringFormat;
    35     private Dictionary<ISymbolicExpressionTreeNode, VisualTreeNode<ISymbolicExpressionTreeNode>> visualTreeNodes;
    36     private Dictionary<Tuple<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>, VisualTreeNodeConnection> visualLines;
    37     private ILayoutEngine<ISymbolicExpressionTreeNode> layoutEngine;
    38 
    39     private const int preferredNodeWidth = 70;
    40     private const int preferredNodeHeight = 46;
    41     private int minHorizontalDistance = 30;
    42     private int minVerticalDistance = 30;
     31    private StringFormat stringFormat;
     32    private Dictionary<ISymbolicExpressionTreeNode, VisualSymbolicExpressionTreeNode> visualTreeNodes;
     33    private Dictionary<Tuple<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>, VisualSymbolicExpressionTreeNodeConnection> visualLines;
    4334
    4435    public SymbolicExpressionTreeChart() {
     
    4940      this.lineColor = Color.Black;
    5041      this.backgroundColor = Color.White;
    51       this.textFont = new Font(FontFamily.GenericSansSerif, 12);
    52 
    53       visualTreeNodes = new Dictionary<ISymbolicExpressionTreeNode, VisualTreeNode<ISymbolicExpressionTreeNode>>();
    54       visualLines = new Dictionary<Tuple<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>, VisualTreeNodeConnection>();
    55 
    56       layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>(n => n.Subtrees) {
    57         NodeWidth = preferredNodeWidth,
    58         NodeHeight = preferredNodeHeight,
    59         HorizontalSpacing = minHorizontalDistance,
    60         VerticalSpacing = minVerticalDistance
    61       };
    62       reingoldTilfordToolStripMenuItem.Checked = true;
     42      this.textFont = new Font("Times New Roman", 8);
    6343    }
    6444
     
    6848    }
    6949
    70     #region Public properties
    7150    private int spacing;
    7251    public int Spacing {
     
    11089      set {
    11190        tree = value;
     91        visualTreeNodes = new Dictionary<ISymbolicExpressionTreeNode, VisualSymbolicExpressionTreeNode>();
     92        visualLines = new Dictionary<Tuple<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>, VisualSymbolicExpressionTreeNodeConnection>();
     93        if (tree != null) {
     94          foreach (ISymbolicExpressionTreeNode node in tree.IterateNodesPrefix()) {
     95            visualTreeNodes[node] = new VisualSymbolicExpressionTreeNode(node);
     96            if (node.Parent != null) visualLines[Tuple.Create(node.Parent, node)] = new VisualSymbolicExpressionTreeNodeConnection();
     97          }
     98        }
    11299        Repaint();
    113100      }
     
    119106      set { suspendRepaint = value; }
    120107    }
    121     #endregion
    122108
    123109    protected override void OnPaint(PaintEventArgs e) {
     
    129115      if (this.Width <= 1 || this.Height <= 1)
    130116        this.image = new Bitmap(1, 1);
    131       else {
     117      else
    132118        this.image = new Bitmap(Width, Height);
    133       }
    134119      this.Repaint();
    135     }
    136 
    137     public event EventHandler Repainted;//expose this event to notify the parent control that the tree was repainted
    138     protected virtual void OnRepaint(object sender, EventArgs e) {
    139       var repainted = Repainted;
    140       if (repainted != null) {
    141         repainted(sender, e);
    142       }
    143120    }
    144121
     
    147124        this.GenerateImage();
    148125        this.Refresh();
    149         OnRepaint(this, EventArgs.Empty);
    150126      }
    151127    }
     
    158134          foreach (var visualNode in visualTreeNodes.Values) {
    159135            DrawTreeNode(graphics, visualNode);
    160             if (visualNode.Content.SubtreeCount > 0) {
    161               foreach (var visualSubtree in visualNode.Content.Subtrees.Select(s => visualTreeNodes[s])) {
    162                 DrawLine(graphics, visualNode, visualSubtree);
    163               }
    164             }
    165136          }
    166137        }
     
    169140    }
    170141
    171     public void RepaintNode(VisualTreeNode<ISymbolicExpressionTreeNode> visualNode) {
     142    public void RepaintNode(VisualSymbolicExpressionTreeNode visualNode) {
    172143      if (!suspendRepaint) {
    173144        using (var graphics = Graphics.FromImage(image)) {
     
    186157        graphics.Clear(backgroundColor);
    187158        if (tree != null) {
    188           DrawFunctionTree(graphics, preferredNodeWidth, preferredNodeHeight, minHorizontalDistance, minVerticalDistance);
    189         }
    190       }
    191     }
    192 
    193     public VisualTreeNode<ISymbolicExpressionTreeNode> GetVisualSymbolicExpressionTreeNode(ISymbolicExpressionTreeNode symbolicExpressionTreeNode) {
     159          int height = this.Height / tree.Depth;
     160          DrawFunctionTree(tree, graphics, 0, 0, this.Width, height);
     161        }
     162      }
     163    }
     164
     165    public VisualSymbolicExpressionTreeNode GetVisualSymbolicExpressionTreeNode(ISymbolicExpressionTreeNode symbolicExpressionTreeNode) {
    194166      if (visualTreeNodes.ContainsKey(symbolicExpressionTreeNode))
    195167        return visualTreeNodes[symbolicExpressionTreeNode];
     
    197169    }
    198170
    199     public VisualTreeNodeConnection GetVisualSymbolicExpressionTreeNodeConnection(ISymbolicExpressionTreeNode parent, ISymbolicExpressionTreeNode child) {
     171    public VisualSymbolicExpressionTreeNodeConnection GetVisualSymbolicExpressionTreeNodeConnection(ISymbolicExpressionTreeNode parent, ISymbolicExpressionTreeNode child) {
    200172      if (child.Parent != parent) throw new ArgumentException();
    201173      var key = Tuple.Create(parent, child);
    202       VisualTreeNodeConnection connection = null;
     174      VisualSymbolicExpressionTreeNodeConnection connection = null;
    203175      visualLines.TryGetValue(key, out connection);
    204176      return connection;
     
    214186
    215187    protected virtual void SymbolicExpressionTreeChart_MouseClick(object sender, MouseEventArgs e) {
    216       var visualTreeNode = FindVisualSymbolicExpressionTreeNodeAt(e.X, e.Y);
     188      VisualSymbolicExpressionTreeNode visualTreeNode = FindVisualSymbolicExpressionTreeNodeAt(e.X, e.Y);
    217189      if (visualTreeNode != null) {
    218190        OnSymbolicExpressionTreeNodeClicked(visualTreeNode, e);
     
    228200
    229201    protected virtual void SymbolicExpressionTreeChart_MouseDoubleClick(object sender, MouseEventArgs e) {
    230       VisualTreeNode<ISymbolicExpressionTreeNode> visualTreeNode = FindVisualSymbolicExpressionTreeNodeAt(e.X, e.Y);
     202      VisualSymbolicExpressionTreeNode visualTreeNode = FindVisualSymbolicExpressionTreeNodeAt(e.X, e.Y);
    231203      if (visualTreeNode != null)
    232204        OnSymbolicExpressionTreeNodeDoubleClicked(visualTreeNode, e);
     
    240212    }
    241213
    242     private VisualTreeNode<ISymbolicExpressionTreeNode> draggedSymbolicExpressionTree;
     214    private VisualSymbolicExpressionTreeNode draggedSymbolicExpressionTree;
    243215    private MouseButtons dragButtons;
    244216    private void SymbolicExpressionTreeChart_MouseDown(object sender, MouseEventArgs e) {
     
    252224
    253225    private void SymbolicExpressionTreeChart_MouseMove(object sender, MouseEventArgs e) {
    254       VisualTreeNode<ISymbolicExpressionTreeNode> visualTreeNode = FindVisualSymbolicExpressionTreeNodeAt(e.X, e.Y);
     226      VisualSymbolicExpressionTreeNode visualTreeNode = FindVisualSymbolicExpressionTreeNodeAt(e.X, e.Y);
    255227      if (draggedSymbolicExpressionTree != null &&
    256228        draggedSymbolicExpressionTree != visualTreeNode) {
     
    267239    }
    268240
    269     public VisualTreeNode<ISymbolicExpressionTreeNode> FindVisualSymbolicExpressionTreeNodeAt(int x, int y) {
     241    public VisualSymbolicExpressionTreeNode FindVisualSymbolicExpressionTreeNodeAt(int x, int y) {
    270242      foreach (var visualTreeNode in visualTreeNodes.Values) {
    271243        if (x >= visualTreeNode.X && x <= visualTreeNode.X + visualTreeNode.Width &&
     
    277249    #endregion
    278250
    279     private void CalculateLayout(int preferredWidth, int preferredHeight, int minHDistance, int minVDistance) {
    280       layoutEngine.NodeWidth = preferredWidth;
    281       layoutEngine.NodeHeight = preferredHeight;
    282       layoutEngine.HorizontalSpacing = minHDistance;
    283       layoutEngine.VerticalSpacing = minVDistance;
    284 
    285       var actualRoot = tree.Root;
    286       if (actualRoot.Symbol is ProgramRootSymbol && actualRoot.SubtreeCount == 1) {
    287         actualRoot = tree.Root.GetSubtree(0);
    288       }
    289 
    290       var visualNodes = layoutEngine.CalculateLayout(actualRoot, Width, Height).ToList();
    291       visualTreeNodes = visualNodes.ToDictionary(x => x.Content, x => x);
    292       visualLines = new Dictionary<Tuple<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>, VisualTreeNodeConnection>();
    293       foreach (var node in visualNodes.Select(n => n.Content)) {
    294         foreach (var subtree in node.Subtrees) {
    295           visualLines.Add(new Tuple<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>(node, subtree), new VisualTreeNodeConnection());
    296         }
    297       }
    298     }
    299 
    300251    #region methods for painting the symbolic expression tree
    301     private void DrawFunctionTree(Graphics graphics, int preferredWidth, int preferredHeight, int minHDistance, int minVDistance) {
    302       CalculateLayout(preferredWidth, preferredHeight, minHDistance, minVDistance);
    303       var visualNodes = visualTreeNodes.Values;
    304       //draw nodes and connections
    305       foreach (var visualNode in visualNodes) {
    306         DrawTreeNode(graphics, visualNode);
    307         var node = visualNode.Content;
    308         foreach (var subtree in node.Subtrees) {
    309           var visualLine = GetVisualSymbolicExpressionTreeNodeConnection(node, subtree);
    310           var visualSubtree = visualTreeNodes[subtree];
    311           var origin = new Point(visualNode.X + visualNode.Width / 2, visualNode.Y + visualNode.Height);
    312           var target = new Point(visualSubtree.X + visualSubtree.Width / 2, visualSubtree.Y);
    313           graphics.Clip = new Region(new Rectangle(Math.Min(origin.X, target.X), origin.Y, Math.Max(origin.X, target.X), target.Y));
    314           using (var linePen = new Pen(visualLine.LineColor)) {
     252    private void DrawFunctionTree(ISymbolicExpressionTree tree, Graphics graphics, int x, int y, int width, int height) {
     253      DrawFunctionTree(tree.Root, graphics, x, y, width, height, Point.Empty);
     254    }
     255
     256    /// <summary>
     257    ///
     258    /// </summary>
     259    /// <param name="functionTree"> function tree to draw</param>
     260    /// <param name="graphics">graphics object to draw on</param>
     261    /// <param name="x">x coordinate of drawing area</param>
     262    /// <param name="y">y coordinate of drawing area</param>
     263    /// <param name="width">width of drawing area</param>
     264    /// <param name="height">height of drawing area</param>
     265    private void DrawFunctionTree(ISymbolicExpressionTreeNode node, Graphics graphics, int x, int y, int width, int height, Point connectionPoint) {
     266      VisualSymbolicExpressionTreeNode visualTreeNode = visualTreeNodes[node];
     267      float center_x = x + width / 2;
     268      float center_y = y + height / 2;
     269      int actualWidth = width - spacing;
     270      int actualHeight = height - spacing;
     271
     272      using (var textBrush = new SolidBrush(visualTreeNode.TextColor))
     273      using (var nodeLinePen = new Pen(visualTreeNode.LineColor))
     274      using (var nodeFillBrush = new SolidBrush(visualTreeNode.FillColor)) {
     275
     276        //calculate size of node
     277        if (actualWidth >= visualTreeNode.PreferredWidth && actualHeight >= visualTreeNode.PreferredHeight) {
     278          visualTreeNode.Width = visualTreeNode.PreferredWidth;
     279          visualTreeNode.Height = visualTreeNode.PreferredHeight;
     280          visualTreeNode.X = (int)center_x - visualTreeNode.Width / 2;
     281          visualTreeNode.Y = (int)center_y - visualTreeNode.Height / 2;
     282        }
     283          //width too small to draw in desired sized
     284        else if (actualWidth < visualTreeNode.PreferredWidth && actualHeight >= visualTreeNode.PreferredHeight) {
     285          visualTreeNode.Width = actualWidth;
     286          visualTreeNode.Height = visualTreeNode.PreferredHeight;
     287          visualTreeNode.X = x;
     288          visualTreeNode.Y = (int)center_y - visualTreeNode.Height / 2;
     289        }
     290          //height too small to draw in desired sized
     291        else if (actualWidth >= visualTreeNode.PreferredWidth && actualHeight < visualTreeNode.PreferredHeight) {
     292          visualTreeNode.Width = visualTreeNode.PreferredWidth;
     293          visualTreeNode.Height = actualHeight;
     294          visualTreeNode.X = (int)center_x - visualTreeNode.Width / 2;
     295          visualTreeNode.Y = y;
     296        }
     297          //width and height too small to draw in desired size
     298        else {
     299          visualTreeNode.Width = actualWidth;
     300          visualTreeNode.Height = actualHeight;
     301          visualTreeNode.X = x;
     302          visualTreeNode.Y = y;
     303        }
     304
     305        //draw terminal node
     306        if (node.SubtreeCount == 0) {
     307          graphics.FillRectangle(nodeFillBrush, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height);
     308          graphics.DrawRectangle(nodeLinePen, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height);
     309        } else {
     310          graphics.FillEllipse(nodeFillBrush, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height);
     311          graphics.DrawEllipse(nodeLinePen, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height);
     312        }
     313
     314        //draw name of symbol
     315        var text = node.ToString();
     316        graphics.DrawString(text, textFont, textBrush, new RectangleF(visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height), stringFormat);
     317
     318        //draw connection line to parent node
     319        if (!connectionPoint.IsEmpty && node.Parent != null) {
     320          var visualLine = GetVisualSymbolicExpressionTreeNodeConnection(node.Parent, node);
     321          using (Pen linePen = new Pen(visualLine.LineColor)) {
    315322            linePen.DashStyle = visualLine.DashStyle;
    316             graphics.DrawLine(linePen, origin, target);
     323            graphics.DrawLine(linePen, connectionPoint, new Point(visualTreeNode.X + visualTreeNode.Width / 2, visualTreeNode.Y));
    317324          }
    318325        }
    319       }
    320     }
    321 
    322     protected void DrawTreeNode(Graphics graphics, VisualTreeNode<ISymbolicExpressionTreeNode> visualTreeNode) {
     326
     327        //calculate areas for the subtrees according to their tree size and call drawFunctionTree
     328        Point connectFrom = new Point(visualTreeNode.X + visualTreeNode.Width / 2, visualTreeNode.Y + visualTreeNode.Height);
     329        int[] xBoundaries = new int[node.SubtreeCount + 1];
     330        xBoundaries[0] = x;
     331        for (int i = 0; i < node.SubtreeCount; i++) {
     332          xBoundaries[i + 1] = (int)(xBoundaries[i] + (width * (double)node.GetSubtree(i).GetLength()) / (node.GetLength() - 1));
     333          DrawFunctionTree(node.GetSubtree(i), graphics, xBoundaries[i], y + height, xBoundaries[i + 1] - xBoundaries[i], height, connectFrom);
     334        }
     335      }
     336    }
     337
     338    protected void DrawTreeNode(VisualSymbolicExpressionTreeNode visualTreeNode) {
     339      using (var graphics = Graphics.FromImage(image)) {
     340        graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
     341        graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
     342        DrawTreeNode(graphics, visualTreeNode);
     343      }
     344    }
     345
     346    protected void DrawTreeNode(Graphics graphics, VisualSymbolicExpressionTreeNode visualTreeNode) {
    323347      graphics.Clip = new Region(new Rectangle(visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width + 1, visualTreeNode.Height + 1));
    324348      graphics.Clear(backgroundColor);
    325       var node = visualTreeNode.Content;
     349      var node = visualTreeNode.SymbolicExpressionTreeNode;
    326350      using (var textBrush = new SolidBrush(visualTreeNode.TextColor))
    327351      using (var nodeLinePen = new Pen(visualTreeNode.LineColor))
     
    340364      }
    341365    }
    342 
    343     protected void DrawLine(Graphics graphics, VisualTreeNode<ISymbolicExpressionTreeNode> startNode, VisualTreeNode<ISymbolicExpressionTreeNode> endNode) {
    344       var origin = new Point(startNode.X + startNode.Width / 2, startNode.Y + startNode.Height);
    345       var target = new Point(endNode.X + endNode.Width / 2, endNode.Y);
    346       graphics.Clip = new Region(new Rectangle(Math.Min(origin.X, target.X), origin.Y, Math.Max(origin.X, target.X), target.Y));
    347       var visualLine = GetVisualSymbolicExpressionTreeNodeConnection(startNode.Content, endNode.Content);
    348       using (var linePen = new Pen(visualLine.LineColor)) {
    349         linePen.DashStyle = visualLine.DashStyle;
    350         graphics.DrawLine(linePen, origin, target);
    351       }
    352     }
    353366    #endregion
     367
    354368    #region save image
    355369    private void saveImageToolStripMenuItem_Click(object sender, EventArgs e) {
     
    362376    }
    363377
    364     public void SaveImageAsBitmap(string filename) {
     378    private void SaveImageAsBitmap(string filename) {
    365379      if (tree == null) return;
    366380      Image image = new Bitmap(Width, Height);
    367381      using (Graphics g = Graphics.FromImage(image)) {
    368         DrawFunctionTree(g, preferredNodeWidth, preferredNodeHeight, minHorizontalDistance, minVerticalDistance);
     382        int height = this.Height / tree.Depth;
     383        DrawFunctionTree(tree, g, 0, 0, Width, height);
    369384      }
    370385      image.Save(filename);
    371386    }
    372387
    373     public void SaveImageAsEmf(string filename) {
     388    private void SaveImageAsEmf(string filename) {
    374389      if (tree == null) return;
    375390      using (Graphics g = CreateGraphics()) {
    376391        using (Metafile file = new Metafile(filename, g.GetHdc())) {
    377392          using (Graphics emfFile = Graphics.FromImage(file)) {
    378             DrawFunctionTree(emfFile, preferredNodeWidth, preferredNodeHeight, minHorizontalDistance, minVerticalDistance);
     393            int height = this.Height / tree.Depth;
     394            DrawFunctionTree(tree, emfFile, 0, 0, Width, height);
    379395          }
    380396        }
     
    383399    }
    384400    #endregion
    385     #region export pgf/tikz
    386     private void exportLatexToolStripMenuItem_Click(object sender, EventArgs e) {
    387       var t = Tree;
    388       if (t == null) return;
    389       using (var dialog = new SaveFileDialog { Filter = "Tex (*.tex)|*.tex" }) {
    390         if (dialog.ShowDialog() != DialogResult.OK) return;
    391         string filename = dialog.FileName.ToLower();
    392         var formatter = new SymbolicExpressionTreeLatexFormatter();
    393         File.WriteAllText(filename, formatter.Format(t));
    394       }
    395     }
    396     #endregion
    397 
    398     private void reingoldTilfordToolStripMenuItem_Click(object sender, EventArgs e) {
    399       minHorizontalDistance = 30;
    400       minVerticalDistance = 30;
    401       layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>(n => n.Subtrees) {
    402         NodeWidth = preferredNodeWidth,
    403         NodeHeight = preferredNodeHeight,
    404         HorizontalSpacing = minHorizontalDistance,
    405         VerticalSpacing = minVerticalDistance
    406       };
    407       reingoldTilfordToolStripMenuItem.Checked = true;
    408       boxesToolStripMenuItem.Checked = false;
    409       Repaint();
    410     }
    411 
    412     private void boxesToolStripMenuItem_Click(object sender, EventArgs e) {
    413       minHorizontalDistance = 5;
    414       minVerticalDistance = 5;
    415       layoutEngine = new BoxesLayoutEngine<ISymbolicExpressionTreeNode>(n => n.Subtrees, n => n.GetLength(), n => n.GetDepth()) {
    416         NodeWidth = preferredNodeWidth,
    417         NodeHeight = preferredNodeHeight,
    418         HorizontalSpacing = minHorizontalDistance,
    419         VerticalSpacing = minVerticalDistance
    420       };
    421       reingoldTilfordToolStripMenuItem.Checked = false;
    422       boxesToolStripMenuItem.Checked = true;
    423       Repaint();
    424     }
    425401  }
    426402}
  • branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionView.Designer.cs

    r11202 r11203  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    5252      // textBox
    5353      //
    54       this.textBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    55             | System.Windows.Forms.AnchorStyles.Left)
    56             | System.Windows.Forms.AnchorStyles.Right)));
     54      this.textBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     55                  | System.Windows.Forms.AnchorStyles.Left)
     56                  | System.Windows.Forms.AnchorStyles.Right)));
    5757      this.textBox.BackColor = System.Drawing.Color.White;
    58       this.textBox.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    5958      this.textBox.Location = new System.Drawing.Point(3, 30);
    6059      this.textBox.Multiline = true;
     
    6766      // formattersComboBox
    6867      //
    69       this.formattersComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    70             | System.Windows.Forms.AnchorStyles.Right)));
     68      this.formattersComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     69                  | System.Windows.Forms.AnchorStyles.Right)));
    7170      this.formattersComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    7271      this.formattersComboBox.FormattingEnabled = true;
  • branches/HiveStatistics/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionView.cs

    r11202 r11203  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3131  [Content(typeof(ISymbolicExpressionTree), false)]
    3232  public partial class SymbolicExpressionView : AsynchronousContentView {
    33     private readonly List<ISymbolicExpressionTreeStringFormatter> treeFormattersList = new List<ISymbolicExpressionTreeStringFormatter>();
     33
     34    List<ISymbolicExpressionTreeStringFormatter> treeFormattersList = new List<ISymbolicExpressionTreeStringFormatter>();
    3435
    3536    public new ISymbolicExpressionTree Content {
     
    4748      }
    4849      if (formattersComboBox.Items.Count > 0)
    49         formattersComboBox.SelectedIndex = treeFormattersList.FindIndex(0, treeFormattersList.Count, (f) => f.Name.Contains("Default"));
     50        formattersComboBox.SelectedIndex = 0;
    5051      else
    5152        formattersComboBox.SelectedIndex = -1;
     
    7879      UpdateTextbox();
    7980    }
    80 
    8181  }
    8282}
Note: See TracChangeset for help on using the changeset viewer.