Changeset 15118


Ignore:
Timestamp:
07/03/17 23:06:13 (7 weeks ago)
Author:
mkommend
Message:

#2794: Merged r15029, r15040, r15044 into stable.

Location:
stable
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views

  • stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/GraphicalSymbolicExpressionTreeView.Designer.cs

    r14186 r15118  
    5959      this.symbolicExpressionTreeChart.Name = "functionTreeChart";
    6060      this.symbolicExpressionTreeChart.Size = new System.Drawing.Size(407, 367);
    61       this.symbolicExpressionTreeChart.Spacing = 5;
    6261      this.symbolicExpressionTreeChart.TabIndex = 0;
    6362      this.symbolicExpressionTreeChart.TextFont = new System.Drawing.Font(FontFamily.GenericSerif, 8F);
  • stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs

    r11120 r15118  
    4040      SecondWalk(layoutRoot, -layoutRoot.Prelim);
    4141      NormalizeCoordinates(layoutNodeMap.Values);
    42       if (height != 0 && width != 0) {
     42      if (width > 0 && height > 0) {
    4343        FitToBounds(width, height, layoutNodeMap.Values);
    4444        Center(width, height, layoutNodeMap.Values);
     
    158158        if (ymax < y) ymax = y;
    159159      }
    160       return new RectangleF(xmin, ymin, xmax + minHorizontalSpacing + NodeWidth, ymax + minVerticalSpacing + NodeHeight);
     160      return new RectangleF(xmin, ymin, xmax + NodeWidth, ymax + NodeHeight);
    161161    }
    162162
  • stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarAllowedChildSymbolsControl.Designer.cs

    r14186 r15118  
    7070      this.symbolicExpressionTreeChart.Name = "allowedChildSymbolsControl";
    7171      this.symbolicExpressionTreeChart.Size = new System.Drawing.Size(645, 386);
    72       this.symbolicExpressionTreeChart.Spacing = 5;
    7372      this.symbolicExpressionTreeChart.SuspendRepaint = false;
    7473      this.symbolicExpressionTreeChart.TabIndex = 0;
  • stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs

    r14186 r15118  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3737    private ILayoutEngine<ISymbolicExpressionTreeNode> layoutEngine;
    3838
    39     private const int preferredNodeWidth = 70;
    40     private const int preferredNodeHeight = 46;
    41     private int minHorizontalDistance = 30;
    42     private int minVerticalDistance = 30;
    43 
    4439    public SymbolicExpressionTreeChart() {
    4540      InitializeComponent();
    4641      this.image = new Bitmap(Width, Height);
    4742      this.stringFormat = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center };
    48       this.spacing = 5;
    4943      this.lineColor = Color.Black;
    5044      this.backgroundColor = Color.White;
     
    5549
    5650      layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>(n => n.Subtrees) {
    57         NodeWidth = preferredNodeWidth,
    58         NodeHeight = preferredNodeHeight,
    59         HorizontalSpacing = minHorizontalDistance,
    60         VerticalSpacing = minVerticalDistance
     51        NodeWidth = PreferredNodeWidth,
     52        NodeHeight = PreferredNodeHeight,
     53        HorizontalSpacing = MinimumHorizontalDistance,
     54        VerticalSpacing = MinimumVerticalDistance
    6155      };
    6256      reingoldTilfordToolStripMenuItem.Checked = true;
     
    6963
    7064    #region Public properties
    71     private int spacing;
    72     public int Spacing {
    73       get { return this.spacing; }
    74       set {
    75         this.spacing = value;
    76         this.Repaint();
     65    private int preferredNodeWidth = 70;
     66    public int PreferredNodeWidth {
     67      get { return preferredNodeWidth; }
     68      set {
     69        preferredNodeWidth = value;
     70        Repaint();
     71      }
     72    }
     73
     74    private int preferredNodeHeight = 46;
     75    public int PreferredNodeHeight {
     76      get { return preferredNodeHeight; }
     77      set {
     78        preferredNodeHeight = value;
     79        Repaint();
     80      }
     81    }
     82
     83    private int minHorizontalDistance = 30;
     84    public int MinimumHorizontalDistance {
     85      get { return minHorizontalDistance; }
     86      set {
     87        minHorizontalDistance = value;
     88        Repaint();
     89      }
     90    }
     91
     92    private int minVerticalDistance = 30;
     93    public int MinimumVerticalDistance {
     94      get { return minVerticalDistance; }
     95      set {
     96        minVerticalDistance = value;
     97        Repaint();
     98      }
     99    }
     100
     101    private int minHorizontalPadding = 20;
     102    public int MinimumHorizontalPadding {
     103      get { return minHorizontalPadding; }
     104      set {
     105        minHorizontalPadding = value;
     106        Repaint();
     107      }
     108    }
     109
     110    private int minVerticalPadding = 20;
     111    public int MinimumVerticalPadding {
     112      get { return minVerticalPadding; }
     113      set {
     114        minVerticalPadding = value;
     115        Repaint();
    77116      }
    78117    }
     
    186225        graphics.Clear(backgroundColor);
    187226        if (tree != null) {
    188           DrawFunctionTree(graphics, preferredNodeWidth, preferredNodeHeight, minHorizontalDistance, minVerticalDistance);
     227          DrawFunctionTree(graphics, PreferredNodeWidth, PreferredNodeHeight, MinimumHorizontalDistance, MinimumVerticalDistance);
    189228        }
    190229      }
     
    287326        actualRoot = tree.Root.GetSubtree(0);
    288327      }
    289 
    290       var visualNodes = layoutEngine.CalculateLayout(actualRoot, Width, Height).ToList();
     328      var visualNodes = layoutEngine.CalculateLayout(actualRoot, Width - MinimumHorizontalPadding, Height - MinimumVerticalPadding).ToList();
     329      // add the padding
     330      foreach (var vn in visualNodes) {
     331        vn.X += MinimumHorizontalPadding / 2;
     332        vn.Y += MinimumVerticalPadding / 2;
     333      }
     334
    291335      visualTreeNodes = visualNodes.ToDictionary(x => x.Content, x => x);
    292336      visualLines = new Dictionary<Tuple<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>, VisualTreeNodeConnection>();
     
    321365    }
    322366
     367    private Action<Brush, int, int, int, int> fill;
     368    private Action<Pen, int, int, int, int> draw;
    323369    protected void DrawTreeNode(Graphics graphics, VisualTreeNode<ISymbolicExpressionTreeNode> visualTreeNode) {
    324370      graphics.Clip = new Region(new Rectangle(visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width + 1, visualTreeNode.Height + 1));
     
    328374      using (var nodeLinePen = new Pen(visualTreeNode.LineColor))
    329375      using (var nodeFillBrush = new SolidBrush(visualTreeNode.FillColor)) {
    330         //draw terminal node
    331         if (node.SubtreeCount == 0) {
    332           graphics.FillRectangle(nodeFillBrush, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height);
    333           graphics.DrawRectangle(nodeLinePen, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height);
     376        var x = visualTreeNode.X;
     377        var y = visualTreeNode.Y;
     378        var w = visualTreeNode.Width - 1;  // allow 1px for the drawing of the line
     379        var h = visualTreeNode.Height - 1; // allow 1px for the drawing of the line
     380        // draw leaf nodes as rectangles and internal nodes as ellipses
     381        if (node.SubtreeCount > 0) {
     382          fill = graphics.FillEllipse; draw = graphics.DrawEllipse;
    334383        } else {
    335           graphics.FillEllipse(nodeFillBrush, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height);
    336           graphics.DrawEllipse(nodeLinePen, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height);
    337         }
     384          fill = graphics.FillRectangle; draw = graphics.DrawRectangle;
     385        }
     386        fill(nodeFillBrush, x, y, w, h);
     387        draw(nodeLinePen, x, y, w, h);
    338388        //draw name of symbol
    339         var text = node.ToString();
    340         graphics.DrawString(text, textFont, textBrush, new RectangleF(visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height), stringFormat);
     389        graphics.DrawString(node.ToString(), textFont, textBrush, new RectangleF(x, y, w, h), stringFormat);
    341390      }
    342391    }
     
    367416      Image image = new Bitmap(Width, Height);
    368417      using (Graphics g = Graphics.FromImage(image)) {
    369         DrawFunctionTree(g, preferredNodeWidth, preferredNodeHeight, minHorizontalDistance, minVerticalDistance, false);
     418        DrawFunctionTree(g, PreferredNodeWidth, PreferredNodeHeight, MinimumHorizontalDistance, MinimumVerticalDistance, false);
    370419      }
    371420      image.Save(filename);
     
    377426        using (Metafile file = new Metafile(filename, g.GetHdc())) {
    378427          using (Graphics emfFile = Graphics.FromImage(file)) {
    379             DrawFunctionTree(emfFile, preferredNodeWidth, preferredNodeHeight, minHorizontalDistance, minVerticalDistance, false);
     428            DrawFunctionTree(emfFile, PreferredNodeWidth, PreferredNodeHeight, MinimumHorizontalDistance, MinimumVerticalDistance, false);
    380429          }
    381430        }
     
    398447
    399448    private void reingoldTilfordToolStripMenuItem_Click(object sender, EventArgs e) {
    400       minHorizontalDistance = 30;
    401       minVerticalDistance = 30;
    402449      layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>(n => n.Subtrees) {
    403         NodeWidth = preferredNodeWidth,
    404         NodeHeight = preferredNodeHeight,
    405         HorizontalSpacing = minHorizontalDistance,
    406         VerticalSpacing = minVerticalDistance
     450        NodeWidth = PreferredNodeWidth,
     451        NodeHeight = PreferredNodeHeight,
     452        HorizontalSpacing = MinimumHorizontalDistance,
     453        VerticalSpacing = MinimumVerticalDistance
    407454      };
    408455      reingoldTilfordToolStripMenuItem.Checked = true;
     
    412459
    413460    private void boxesToolStripMenuItem_Click(object sender, EventArgs e) {
    414       minHorizontalDistance = 5;
    415       minVerticalDistance = 5;
    416461      layoutEngine = new BoxesLayoutEngine<ISymbolicExpressionTreeNode>(n => n.Subtrees, n => n.GetLength(), n => n.GetDepth()) {
    417         NodeWidth = preferredNodeWidth,
    418         NodeHeight = preferredNodeHeight,
    419         HorizontalSpacing = minHorizontalDistance,
    420         VerticalSpacing = minVerticalDistance
     462        NodeWidth = PreferredNodeWidth,
     463        NodeHeight = PreferredNodeHeight,
     464        HorizontalSpacing = MinimumHorizontalDistance,
     465        VerticalSpacing = MinimumVerticalDistance
    421466      };
    422467      reingoldTilfordToolStripMenuItem.Checked = false;
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.Designer.cs

    r14186 r15118  
    187187      this.treeChart.Name = "treeChart";
    188188      this.treeChart.Size = new System.Drawing.Size(201, 348);
    189       this.treeChart.Spacing = 5;
    190189      this.treeChart.SuspendRepaint = false;
    191190      this.treeChart.TabIndex = 0;
Note: See TracChangeset for help on using the changeset viewer.