Ignore:
Timestamp:
05/06/14 15:33:50 (5 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.