Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/07/14 16:23:41 (10 years ago)
Author:
mkommend
Message:

#2076: Simplified the API of the tree layout engines.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/Formatters/SymbolicExpressionTreeLatexFormatter.cs

    r10520 r10565  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Drawing;
    2425using System.Globalization;
    2526using System.Linq;
     
    3637      {"StartSymbol","RPB"}
    3738    };
    38     private readonly ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode> layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>();
     39
     40    private readonly ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode> layoutEngine;
    3941
    4042    public SymbolicExpressionTreeLatexFormatter()
    4143      : base("LaTeX/PDF Formatter", "Formatter for symbolic expression trees for use with latex package tikz.") {
    42       layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode> {
     44      layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>(n => n.Subtrees) {
    4345        HorizontalSpacing = 2,
    4446        VerticalSpacing = 2,
     
    5759
    5860    public string Format(ISymbolicExpressionTree symbolicExpressionTree) {
    59       layoutEngine.Reset();
    6061      var root = symbolicExpressionTree.Root;
    6162      var actualRoot = root.SubtreeCount == 0 ? root.GetSubtree(0) : root;
    62       layoutEngine.Initialize(actualRoot, x => x.Subtrees);
    63       layoutEngine.CalculateLayout();
    64       var nodeCoordinates = layoutEngine.GetCoordinates();
     63      var nodeCoordinates = layoutEngine.CalculateLayout(actualRoot).ToDictionary(n => n.Content, n => new PointF(n.X, n.Y));
    6564      var sb = new StringBuilder();
    6665      var nl = Environment.NewLine;
Note: See TracChangeset for help on using the changeset viewer.