Ignore:
Timestamp:
02/28/14 11:56:15 (6 years ago)
Author:
bburlacu
Message:

#2076: Got rid of layout adapters. Extracted the previous drawing code and made it into another layout engine called the BoxesLayoutEngine (because it divides the areas necessary for each subtree into boxes and recursively applies the layout). Simplified usage of layout engine so that most of the things are handled internally, and the user just has to provide some lambdas telling the engine how to navigate the original tree. Added context option in the SymbolicExpressionTreeChart to choose which layout engine to use for tree drawing. Moved the SymbolicExpressionTreeLatexFormatter to the HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views assembly because it depends on the layout engine.

Location:
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/Formatters
Files:
1 added
1 moved

Legend:

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

    r10500 r10520  
    2828using HeuristicLab.Core;
    2929
    30 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     30namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
    3131  [Item("LaTeX/PDF Formatter", "Formatter for symbolic expression trees for use with latex package tikz.")]
    3232  public class SymbolicExpressionTreeLatexFormatter : NamedItem, ISymbolicExpressionTreeStringFormatter {
     
    3737    };
    3838    private readonly ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode> layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>();
    39     private readonly SymbolicExpressionTreeLayoutAdapter layoutAdapter = new SymbolicExpressionTreeLayoutAdapter();
    4039
    4140    public SymbolicExpressionTreeLatexFormatter()
    4241      : base("LaTeX/PDF Formatter", "Formatter for symbolic expression trees for use with latex package tikz.") {
    43       layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>();
     42      layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode> {
     43        HorizontalSpacing = 2,
     44        VerticalSpacing = 2,
     45        NodeWidth = 8,
     46        NodeHeight = 4
     47      };
    4448    }
    4549
     
    5458    public string Format(ISymbolicExpressionTree symbolicExpressionTree) {
    5559      layoutEngine.Reset();
    56       var layoutNodes = layoutAdapter.Convert(symbolicExpressionTree).ToList();
    57       layoutEngine.Root = layoutNodes[0];
    58       layoutEngine.AddNodes(layoutNodes);
     60      var root = symbolicExpressionTree.Root;
     61      var actualRoot = root.SubtreeCount == 0 ? root.GetSubtree(0) : root;
     62      layoutEngine.Initialize(actualRoot, x => x.Subtrees);
    5963      layoutEngine.CalculateLayout();
    60       var nodeCoordinates = layoutEngine.GetNodeCoordinates();
     64      var nodeCoordinates = layoutEngine.GetCoordinates();
    6165      var sb = new StringBuilder();
    6266      var nl = Environment.NewLine;
Note: See TracChangeset for help on using the changeset viewer.