Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/08/14 17:26:32 (10 years ago)
Author:
bburlacu
Message:

#1772: Added default font, pen, and brush for the graphical components (the idea is to save memory by sharing default pens and brushes - not allocating new ones all the time), added support for tracing mutation operations

File:
1 edited

Legend:

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

    r10797 r10827  
    4141
    4242    private const int labelHeight = 30;
     43
     44    private readonly SolidBrush defaultBrush;
     45    private readonly Pen defaultPen;
     46    private readonly Font defaultFont;
    4347
    4448    public ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode> LayoutEngine { get; set; }
     
    127131      PreferredNodeHeight = 40;
    128132      Group = new Group(chart);
     133
     134      defaultBrush = new SolidBrush(Color.Transparent);
     135      defaultPen = new Pen(Color.Black);
     136      defaultFont = new Font(FontFamily.GenericSansSerif, 12, GraphicsUnit.Pixel);
    129137    }
    130138    public SymbolicExpressionTreeTile(IChart chart, ISymbolicExpressionTree tree)
     
    142150      var visualNodes = LayoutEngine.CalculateLayout(actualRoot).ToList();
    143151
    144       var font = new Font(FontFamily.GenericSansSerif, 10, GraphicsUnit.Pixel);
    145 
    146152      var visualNodeMap = visualNodes.ToDictionary(x => x.Content, x => x);
    147153
     
    154160        var shortenedLabel = ShortenLabel(node);
    155161        if (node.SubtreeCount == 0) {
    156           rectangularPrimitive = new Rectangle(Chart, lowerLeft, upperRight) { Font = font, Text = shortenedLabel };
     162          rectangularPrimitive = new Rectangle(Chart, lowerLeft, upperRight) {
     163            Font = defaultFont, Text = shortenedLabel, Brush = defaultBrush, Pen = defaultPen, MaximumFontSize = 12f
     164          };
    157165        } else {
    158           rectangularPrimitive = new Ellipse(Chart, lowerLeft, upperRight) { Font = font, Text = shortenedLabel };
     166          rectangularPrimitive = new Ellipse(Chart, lowerLeft, upperRight) {
     167            Font = defaultFont, Text = shortenedLabel, Brush = defaultBrush, Pen = defaultPen, MaximumFontSize = 12f
     168          };
    159169        }
    160170
     
    189199      // draw a primitive to display the label
    190200      var labelRect = new Rectangle(this.Chart, new PointD(0, height), new PointD(width, height + labelHeight)) {
    191         Pen = new Pen(Color.Black),
    192         Brush = new SolidBrush(Color.Transparent),
     201        Pen = defaultPen,
     202        Brush = defaultBrush,
    193203        Text = Label,
    194         Font = new Font(FontFamily.GenericSansSerif, 12)
     204        Font = defaultFont
    195205      };
    196206      this.Add(labelRect);
     
    200210
    201211      var rectangle = new Rectangle(this.Chart, new PointD(0, 0), new PointD(Size.Width, Size.Height)) {
    202         Pen = new Pen(Color.Gray),
    203         Brush = new SolidBrush(Color.Transparent)
     212        Pen = defaultPen,
     213        Brush = defaultBrush
    204214      };
    205215      this.Add(rectangle);
Note: See TracChangeset for help on using the changeset viewer.