Free cookie consent management tool by TermsFeed Policy Generator

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

#1772: Improved FragmentGraphView.

File:
1 edited

Legend:

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

    r10729 r10730  
    3838    public int PreferredNodeHeight { get; set; }
    3939
     40    private Size size;
    4041    public Size Size {
    41       get {
    42         int xmin = 0, ymin = 0, xmax = 0, ymax = 0;
    43 
    44         foreach (var p in Primitives.OfType<RectangularPrimitiveBase>()) {
    45           if (xmin > p.LowerLeft.X) xmin = (int)Math.Floor(p.LowerLeft.X);
    46           if (xmax < p.UpperRight.X) xmax = (int)Math.Ceiling(p.UpperRight.X);
    47           if (ymin > p.LowerLeft.Y) ymin = (int)Math.Floor(p.LowerLeft.Y);
    48           if (ymax < p.UpperRight.Y) ymax = (int)Math.Ceiling(p.UpperRight.Y);
    49         }
    50 
    51         return new Size(xmax - xmin, ymax - ymin);
    52       }
     42      private set { size = value; }
     43      get { return size; }
    5344    }
    5445
     
    123114      LayoutEngine.NodeHeight = PreferredNodeHeight;
    124115
    125       var visualNodes = LayoutEngine.CalculateLayout(actualRoot);
     116      var visualNodes = LayoutEngine.CalculateLayout(actualRoot).ToList();
    126117
    127118      var font = new Font(FontFamily.GenericSansSerif, 10, GraphicsUnit.Pixel);
     
    157148        }
    158149      }
    159 
    160       // add a bounding rectangle and flip primitives vertically
     150      int xmin = 0, ymin = 0, xmax = 0, ymax = 0;
     151      foreach (var rpb in Primitives.OfType<RectangularPrimitiveBase>()) {
     152        if (xmin > rpb.LowerLeft.X) xmin = (int)Math.Floor(rpb.LowerLeft.X);
     153        if (xmax < rpb.UpperRight.X) xmax = (int)Math.Ceiling(rpb.UpperRight.X);
     154        if (ymin > rpb.LowerLeft.Y) ymin = (int)Math.Floor(rpb.LowerLeft.Y);
     155        if (ymax < rpb.UpperRight.Y) ymax = (int)Math.Ceiling(rpb.UpperRight.Y);
     156      }
     157      Size = new Size(xmax - xmin, ymax - ymin);
     158      var width = Size.Width;
     159      var height = Size.Height;
    161160      // draw a rectangle to mark the countour of this tile
    162       var size = this.Size;
    163       var height = size.Height;
    164       var rectangle = new Rectangle(this.Chart, new PointD(0, 0), new PointD(size.Width, size.Height)) {
     161      var rectangle = new Rectangle(this.Chart, new PointD(0, 0), new PointD(width, height)) {
    165162        Pen = new Pen(Color.Gray),
    166163        Brush = new SolidBrush(Color.Transparent)
     
    168165      this.Add(rectangle);
    169166
     167      // flip primitives vertically
    170168      foreach (var primitive in Primitives) {
    171169        var rpb = primitive as RectangularPrimitiveBase;
    172170        if (rpb != null) {
    173171          rpb.SetPosition(rpb.LowerLeft.X, height - rpb.UpperRight.Y, rpb.UpperRight.X, height - rpb.LowerLeft.Y);
     172
    174173        } else {
    175174          var line = primitive as LinearPrimitiveBase;
Note: See TracChangeset for help on using the changeset viewer.