Changeset 3502


Ignore:
Timestamp:
04/23/10 00:31:02 (12 years ago)
Author:
swagner
Message:

Implemented reviewers' comments (#893)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.TravelingSalesman.Views/3.3/PathTSPTourView.cs

    r3454 r3502  
    104104
    105105            int border = 20;
    106             double xStep = (pictureBox.Width - 2 * border) / (xMax - xMin);
    107             double yStep = (pictureBox.Height - 2 * border) / (yMax - yMin);
     106            double xStep = xMax != xMin ? (pictureBox.Width - 2 * border) / (xMax - xMin) : 1;
     107            double yStep = yMax != yMin ? (pictureBox.Height - 2 * border) / (yMax - yMin) : 1;
    108108
    109109            Point[] points = new Point[coordinates.Rows];
     
    112112                                    bitmap.Height - (border + ((int)((coordinates[i, 1] - yMin) * yStep))));
    113113
    114             Graphics graphics = Graphics.FromImage(bitmap);
    115             if ((permutation != null) && (permutation.Length == coordinates.Rows) && (permutation.Validate())) {
    116               Point[] tour = new Point[permutation.Length];
    117               for (int i = 0; i < permutation.Length; i++) {
    118                 tour[i] = points[permutation[i]];
     114            using (Graphics graphics = Graphics.FromImage(bitmap)) {
     115              if ((permutation != null) && (permutation.Length == coordinates.Rows) && (permutation.Validate())) {
     116                Point[] tour = new Point[permutation.Length];
     117                for (int i = 0; i < permutation.Length; i++) {
     118                  tour[i] = points[permutation[i]];
     119                }
     120                graphics.DrawPolygon(Pens.Black, tour);
    119121              }
    120               graphics.DrawPolygon(Pens.Black, tour);
     122              for (int i = 0; i < points.Length; i++)
     123                graphics.FillRectangle(Brushes.Red, points[i].X - 2, points[i].Y - 2, 6, 6);
    121124            }
    122             for (int i = 0; i < points.Length; i++)
    123               graphics.FillRectangle(Brushes.Red, points[i].X - 2, points[i].Y - 2, 6, 6);
    124             graphics.Dispose();
    125125          }
    126126          pictureBox.Image = bitmap;
Note: See TracChangeset for help on using the changeset viewer.