Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10799


Ignore:
Timestamp:
05/06/14 15:33:50 (11 years ago)
Author:
bburlacu
Message:

#2076: Improved visual aspect of trees using the Boxes layout engine (decreased horizontal spacing to a minimum of 1px). Refactored some code in the InteractiveSymbolicDataAnalysisSolutionSimplifierView to throw an exception when the visual node content is null, and to only update the tree when necessary.

Location:
trunk/sources
Files:
2 edited

Legend:

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

    r10565 r10799  
    3939    private const int preferredNodeWidth = 70;
    4040    private const int preferredNodeHeight = 46;
    41     private const int minHorizontalDistance = 30;
    42     private const int minVerticalDistance = 30;
     41    private int minHorizontalDistance = 30;
     42    private int minVerticalDistance = 30;
    4343
    4444    public SymbolicExpressionTreeChart() {
     
    6262      reingoldTilfordToolStripMenuItem.Checked = true;
    6363    }
    64 
    65     //private ILayoutEngine<ISymbolicExpressionTreeNode> TreeLayoutEngine {
    66     //  get { return layoutEngine; }
    67     //  set {
    68     //    layoutEngine = value;
    69     //    InitializeLayout();
    70     //    Repaint();
    71     //  }
    72     //}
    7364
    7465    public SymbolicExpressionTreeChart(ISymbolicExpressionTree tree)
     
    412403
    413404    private void reingoldTilfordToolStripMenuItem_Click(object sender, EventArgs e) {
     405      minHorizontalDistance = 30;
    414406      layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>(n => n.Subtrees) {
    415407        NodeWidth = preferredNodeWidth,
     
    424416
    425417    private void boxesToolStripMenuItem_Click(object sender, EventArgs e) {
     418      minHorizontalDistance = 1; // the boxes layout engine has no horizontal requirements, it automatically spaces nodes with boxes
    426419      layoutEngine = new BoxesLayoutEngine<ISymbolicExpressionTreeNode>(n => n.Subtrees, n => n.GetLength(), n => n.GetDepth()) {
    427420        NodeWidth = preferredNodeWidth,
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs

    r10564 r10799  
    105105    private void treeChart_SymbolicExpressionTreeNodeDoubleClicked(object sender, MouseEventArgs e) {
    106106      var visualNode = (VisualTreeNode<ISymbolicExpressionTreeNode>)sender;
     107      if (visualNode.Content == null) { throw new Exception("Visual node content cannot be null."); }
    107108      var symbExprTreeNode = (SymbolicExpressionTreeNode)visualNode.Content;
    108       if (symbExprTreeNode == null) return;
    109       var tree = Content.Model.SymbolicExpressionTree;
     109      if (!foldedNodes.ContainsKey(symbExprTreeNode)) return; // constant nodes cannot be folded
    110110      var parent = symbExprTreeNode.Parent;
    111111      int indexOfSubtree = parent.IndexOfSubtree(symbExprTreeNode);
    112       if (foldedNodes.ContainsKey(symbExprTreeNode)) {
    113         // undo node folding
    114         SwitchNodeWithReplacementNode(parent, indexOfSubtree);
    115       }
    116       UpdateModel(tree);
     112      SwitchNodeWithReplacementNode(parent, indexOfSubtree);
     113      UpdateModel(Content.Model.SymbolicExpressionTree);
    117114    }
    118115
    119116    private void SwitchNodeWithReplacementNode(ISymbolicExpressionTreeNode parent, int subTreeIndex) {
    120117      ISymbolicExpressionTreeNode subTree = parent.GetSubtree(subTreeIndex);
    121       parent.RemoveSubtree(subTreeIndex);
    122118      if (foldedNodes.ContainsKey(subTree)) {
     119        parent.RemoveSubtree(subTreeIndex);
    123120        var replacementNode = foldedNodes[subTree];
    124121        parent.InsertSubtree(subTreeIndex, replacementNode);
     
    137134
    138135        if (!(treeNode is ConstantTreeNode) && nodeImpacts.ContainsKey(treeNode)) {
     136          visualTree.ToolTip = visualTree.Content.ToString(); // to avoid duplicate tooltips
    139137          double impact = nodeImpacts[treeNode];
    140138
Note: See TracChangeset for help on using the changeset viewer.