Changeset 3502 for trunk/sources
- Timestamp:
- 04/23/10 00:31:02 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.TravelingSalesman.Views/3.3/PathTSPTourView.cs
r3454 r3502 104 104 105 105 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; 108 108 109 109 Point[] points = new Point[coordinates.Rows]; … … 112 112 bitmap.Height - (border + ((int)((coordinates[i, 1] - yMin) * yStep)))); 113 113 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); 119 121 } 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); 121 124 } 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();125 125 } 126 126 pictureBox.Image = bitmap;
Note: See TracChangeset
for help on using the changeset viewer.