Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/14/18 11:36:59 (6 years ago)
Author:
abeham
Message:

#2817: updated to trunk r15680

Location:
branches/2817-BinPackingSpeedup
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2817-BinPackingSpeedup

  • branches/2817-BinPackingSpeedup/HeuristicLab.Problems.TestFunctions.Views/3.3/SingleObjectiveTestFunctionSolutionView.cs

    r14185 r16140  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2222using System;
    2323using System.Drawing;
     24using System.Linq;
    2425using System.Windows.Forms;
    2526using HeuristicLab.Core.Views;
     
    136137
    137138    private void GenerateImage() {
    138       if (pictureBox.Enabled && pictureBox.Width > 0 && pictureBox.Height > 0) {
    139         if (Content == null) {
    140           pictureBox.Image = null;
    141         } else {
    142           if (backgroundImage == null) {
    143             GenerateBackgroundImage();
    144             pictureBox.Image = backgroundImage;
    145           }
    146           pictureBox.Refresh();
    147           DoubleMatrix bounds = Content.Bounds;
    148           if (bounds == null) bounds = Content.Evaluator.Bounds;
    149           double xMin = bounds[0, 0], xMax = bounds[0, 1], yMin = bounds[1 % bounds.Rows, 0], yMax = bounds[1 % bounds.Rows, 1];
    150           double xStep = backgroundImage.Width / (xMax - xMin), yStep = backgroundImage.Height / (yMax - yMin);
    151           using (Graphics graphics = pictureBox.CreateGraphics()) {
    152             if (Content.BestKnownRealVector != null) {
    153               Pen cross = new Pen(Brushes.Red, 2.0f);
    154               float a = (float)((Content.BestKnownRealVector[0] - xMin) * xStep);
    155               float b = (float)((Content.BestKnownRealVector[1] - yMin) * yStep);
    156               graphics.DrawLine(cross, a - 4, b - 4, a + 4, b + 4);
    157               graphics.DrawLine(cross, a - 4, b + 4, a + 4, b - 4);
    158             }
    159             if (Content.Population != null) {
    160               foreach (RealVector vector in Content.Population)
    161                 graphics.FillEllipse(Brushes.Blue, (float)((vector[0] - xMin) * xStep - 4), (float)((vector[1] - yMin) * yStep - 4), 8.0f, 8.0f);
    162             }
    163             if (Content.BestRealVector != null) {
    164               graphics.FillEllipse(Brushes.Green, (float)((Content.BestRealVector[0] - xMin) * xStep - 5), (float)((Content.BestRealVector[1] - yMin) * yStep - 5), 10.0f, 10.0f);
    165             }
    166           }
     139      if (!pictureBox.Enabled || pictureBox.Width <= 0 || pictureBox.Height <= 0) return;
     140      if (Content == null) {
     141        pictureBox.Image = null;
     142        return;
     143      }
     144      if (backgroundImage == null) {
     145        GenerateBackgroundImage();
     146        pictureBox.Image = backgroundImage;
     147      }
     148      pictureBox.Refresh();
     149      DoubleMatrix bounds = Content.Bounds;
     150      if (bounds == null) bounds = Content.Evaluator.Bounds;
     151      double xMin = bounds[0, 0], xMax = bounds[0, 1], yMin = bounds[1 % bounds.Rows, 0], yMax = bounds[1 % bounds.Rows, 1];
     152      double xStep = backgroundImage.Width / (xMax - xMin), yStep = backgroundImage.Height / (yMax - yMin);
     153
     154      using (Graphics graphics = pictureBox.CreateGraphics()) {
     155        if (Content.BestKnownRealVector != null && Content.BestKnownRealVector.Length == 2) {
     156          Pen cross = new Pen(Brushes.Red, 2.0f);
     157          float a = (float)((Content.BestKnownRealVector[0] - xMin) * xStep);
     158          float b = (float)((Content.BestKnownRealVector[1] - yMin) * yStep);
     159          graphics.DrawLine(cross, a - 4, b - 4, a + 4, b + 4);
     160          graphics.DrawLine(cross, a - 4, b + 4, a + 4, b - 4);
     161        }
     162        if (Content.Population != null) {
     163          foreach (RealVector vector in Content.Population.Where(x => x.Length == 2))
     164            graphics.FillEllipse(Brushes.Blue, (float)((vector[0] - xMin) * xStep - 4), (float)((vector[1] - yMin) * yStep - 4), 8.0f, 8.0f);
     165        }
     166        if (Content.BestRealVector != null && Content.BestRealVector.Length == 2) {
     167          graphics.FillEllipse(Brushes.Green, (float)((Content.BestRealVector[0] - xMin) * xStep - 5), (float)((Content.BestRealVector[1] - yMin) * yStep - 5), 10.0f, 10.0f);
    167168        }
    168169      }
Note: See TracChangeset for help on using the changeset viewer.