Changeset 15044


Ignore:
Timestamp:
06/22/17 14:15:10 (4 months ago)
Author:
bburlacu
Message:

#2794: Better organize properties and call Repaint() after setting a layout parameter. Remove unused Spacing property.

Location:
trunk/sources
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/GraphicalSymbolicExpressionTreeView.Designer.cs

    r14185 r15044  
    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);
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarAllowedChildSymbolsControl.Designer.cs

    r14185 r15044  
    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;
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs

    r15040 r15044  
    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 int preferredNodeWidth = 70;
    40     public int PreferredNodeWidth {
    41       get { return preferredNodeWidth; }
    42       set { preferredNodeWidth = value; }
    43     }
    44 
    45     private int preferredNodeHeight = 46;
    46     public int PreferredNodeHeight {
    47       get { return preferredNodeHeight; }
    48       set { preferredNodeHeight = value; }
    49     }
    50 
    51     private int minHorizontalDistance = 30;
    52     public int MinimumHorizontalDistance {
    53       get { return minHorizontalDistance; }
    54       set { minHorizontalDistance = value; }
    55     }
    56 
    57     private int minVerticalDistance = 30;
    58     public int MinimumVerticalDistance {
    59       get { return minVerticalDistance; }
    60       set { minVerticalDistance = value; }
    61     }
    62 
    63     private int minHorizontalPadding = 20;
    64     public int MinimumHorizontalPadding {
    65       get { return minHorizontalPadding; }
    66       set { minHorizontalPadding = value; }
    67     }
    68 
    69     private int minVerticalPadding = 20;
    70     public int MinimumVerticalPadding {
    71       get { return minVerticalPadding; }
    72       set { minVerticalPadding = value; }
    73     }
    74 
    7539    public SymbolicExpressionTreeChart() {
    7640      InitializeComponent();
    7741      this.image = new Bitmap(Width, Height);
    7842      this.stringFormat = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center };
    79       this.spacing = 5;
    8043      this.lineColor = Color.Black;
    8144      this.backgroundColor = Color.White;
     
    8649
    8750      layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>(n => n.Subtrees) {
    88         NodeWidth = preferredNodeWidth,
    89         NodeHeight = preferredNodeHeight,
    90         HorizontalSpacing = minHorizontalDistance,
    91         VerticalSpacing = minVerticalDistance
     51        NodeWidth = PreferredNodeWidth,
     52        NodeHeight = PreferredNodeHeight,
     53        HorizontalSpacing = MinimumHorizontalDistance,
     54        VerticalSpacing = MinimumVerticalDistance
    9255      };
    9356      reingoldTilfordToolStripMenuItem.Checked = true;
     
    10063
    10164    #region Public properties
    102     private int spacing;
    103     public int Spacing {
    104       get { return this.spacing; }
    105       set {
    106         this.spacing = value;
    107         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();
    108116      }
    109117    }
     
    217225        graphics.Clear(backgroundColor);
    218226        if (tree != null) {
    219           DrawFunctionTree(graphics, preferredNodeWidth, preferredNodeHeight, minHorizontalDistance, minVerticalDistance);
     227          DrawFunctionTree(graphics, PreferredNodeWidth, PreferredNodeHeight, MinimumHorizontalDistance, MinimumVerticalDistance);
    220228        }
    221229      }
     
    318326        actualRoot = tree.Root.GetSubtree(0);
    319327      }
    320       var visualNodes = layoutEngine.CalculateLayout(actualRoot, Width - minHorizontalPadding, Height - minVerticalPadding).ToList();
     328      var visualNodes = layoutEngine.CalculateLayout(actualRoot, Width - MinimumHorizontalPadding, Height - MinimumVerticalPadding).ToList();
    321329      // add the padding
    322330      foreach (var vn in visualNodes) {
    323         vn.X += minHorizontalPadding / 2;
    324         vn.Y += minVerticalPadding / 2;
     331        vn.X += MinimumHorizontalPadding / 2;
     332        vn.Y += MinimumVerticalPadding / 2;
    325333      }
    326334
     
    408416      Image image = new Bitmap(Width, Height);
    409417      using (Graphics g = Graphics.FromImage(image)) {
    410         DrawFunctionTree(g, preferredNodeWidth, preferredNodeHeight, minHorizontalDistance, minVerticalDistance, false);
     418        DrawFunctionTree(g, PreferredNodeWidth, PreferredNodeHeight, MinimumHorizontalDistance, MinimumVerticalDistance, false);
    411419      }
    412420      image.Save(filename);
     
    418426        using (Metafile file = new Metafile(filename, g.GetHdc())) {
    419427          using (Graphics emfFile = Graphics.FromImage(file)) {
    420             DrawFunctionTree(emfFile, preferredNodeWidth, preferredNodeHeight, minHorizontalDistance, minVerticalDistance, false);
     428            DrawFunctionTree(emfFile, PreferredNodeWidth, PreferredNodeHeight, MinimumHorizontalDistance, MinimumVerticalDistance, false);
    421429          }
    422430        }
     
    439447
    440448    private void reingoldTilfordToolStripMenuItem_Click(object sender, EventArgs e) {
    441       minHorizontalDistance = 30;
    442       minVerticalDistance = 30;
    443449      layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>(n => n.Subtrees) {
    444         NodeWidth = preferredNodeWidth,
    445         NodeHeight = preferredNodeHeight,
    446         HorizontalSpacing = minHorizontalDistance,
    447         VerticalSpacing = minVerticalDistance
     450        NodeWidth = PreferredNodeWidth,
     451        NodeHeight = PreferredNodeHeight,
     452        HorizontalSpacing = MinimumHorizontalDistance,
     453        VerticalSpacing = MinimumVerticalDistance
    448454      };
    449455      reingoldTilfordToolStripMenuItem.Checked = true;
     
    453459
    454460    private void boxesToolStripMenuItem_Click(object sender, EventArgs e) {
    455       minHorizontalDistance = 5;
    456       minVerticalDistance = 5;
    457461      layoutEngine = new BoxesLayoutEngine<ISymbolicExpressionTreeNode>(n => n.Subtrees, n => n.GetLength(), n => n.GetDepth()) {
    458         NodeWidth = preferredNodeWidth,
    459         NodeHeight = preferredNodeHeight,
    460         HorizontalSpacing = minHorizontalDistance,
    461         VerticalSpacing = minVerticalDistance
     462        NodeWidth = PreferredNodeWidth,
     463        NodeHeight = PreferredNodeHeight,
     464        HorizontalSpacing = MinimumHorizontalDistance,
     465        VerticalSpacing = MinimumVerticalDistance
    462466      };
    463467      reingoldTilfordToolStripMenuItem.Checked = false;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.Designer.cs

    r14185 r15044  
    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.