Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/15/14 17:08:35 (10 years ago)
Author:
bburlacu
Message:

#1772: Refactored subtree tracing functionality and moved it from the view into a separate static class. Shortened symbol names in the FragmentGraphView so that trees are displayed more nicely.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeTile.cs

    r10746 r10752  
    142142
    143143        RectangularPrimitiveBase rectangularPrimitive;
     144        var label = ShortenLabel(node);
    144145        if (node.SubtreeCount == 0) {
    145           rectangularPrimitive = new Rectangle(Chart, lowerLeft, upperRight) { Font = font, Text = visualNode.Content.ToString() };
     146          rectangularPrimitive = new Rectangle(Chart, lowerLeft, upperRight) { Font = font, Text = label };
    146147        } else {
    147           rectangularPrimitive = new Ellipse(Chart, lowerLeft, upperRight) { Font = font, Text = visualNode.Content.ToString() };
     148          rectangularPrimitive = new Ellipse(Chart, lowerLeft, upperRight) { Font = font, Text = label };
    148149        }
    149150
     
    202203      base.Draw(graphics);
    203204    }
     205
     206    private string ShortenLabel(ISymbolicExpressionTreeNode node) {
     207      var term = node as SymbolicExpressionTreeTerminalNode;
     208      if (term != null) {
     209        var parts = term.ToString().Split(' '); // split by space
     210        if (parts.Length == 1) {
     211          return parts[0].Substring(0, 5);
     212        } else {
     213          return parts[0].Substring(0, 5) + parts[1];
     214        }
     215      }
     216      return node.Symbol.ToString().Substring(0, 3);
     217    }
    204218  }
    205219}
Note: See TracChangeset for help on using the changeset viewer.