Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/21/12 15:28:50 (12 years ago)
Author:
svonolfe
Message:

Added color palette (#1177)

Location:
branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/CVRPPDTWView.cs

    r6851 r7858  
    4242      IntArray pickupDeliveryLocation = Content.PickupDeliveryLocation;
    4343
    44       Pen[] pens = {new Pen(Color.FromArgb(92,20,237)), new Pen(Color.FromArgb(237,183,20)), new Pen(Color.FromArgb(237,20,219)), new Pen(Color.FromArgb(20,237,76)),
    45                     new Pen(Color.FromArgb(237,61,20)), new Pen(Color.FromArgb(115,78,26)), new Pen(Color.FromArgb(20,237,229)), new Pen(Color.FromArgb(39,101,19)),
    46                     new Pen(Color.FromArgb(230,170,229)), new Pen(Color.FromArgb(142,136,89)), new Pen(Color.FromArgb(157,217,166)), new Pen(Color.FromArgb(31,19,101)),
    47                     new Pen(Color.FromArgb(173,237,20)), new Pen(Color.FromArgb(230,231,161)), new Pen(Color.FromArgb(142,89,89)), new Pen(Color.FromArgb(93,89,142)),
    48                     new Pen(Color.FromArgb(146,203,217)), new Pen(Color.FromArgb(101,19,75)), new Pen(Color.FromArgb(198,20,237)), new Pen(Color.FromArgb(185,185,185)),
    49                     new Pen(Color.FromArgb(179,32,32)), new Pen(Color.FromArgb(18,119,115)), new Pen(Color.FromArgb(104,158,239)), new Pen(Color.Black)};
    50 
    5144      Pen flowPen = new Pen(Brushes.Red, 3);
    5245      flowPen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
     
    6962          if (Solution != null) {
    7063            int currentTour = 0;
    71             foreach (Tour tour in Solution.GetTours()) {
     64
     65            List<Tour> tours = Solution.GetTours();
     66            List<Pen> pens = GetColors(tours.Count);
     67
     68            foreach (Tour tour in tours) {
    7269              double t = 0.0;
    7370              Point[] tourPoints = new Point[tour.Stops.Count + 2];
     
    122119
    123120              if (!drawFlow)
    124                 graphics.DrawPolygon(pens[((currentTour >= pens.Length) ? (pens.Length - 1) : (currentTour))], tourPoints);
     121                graphics.DrawPolygon(pens[currentTour], tourPoints);
    125122
    126123              for (int i = 0; i < tour.Stops.Count; i++) {
     
    142139              currentTour++;
    143140            }
     141
     142            for (int i = 0; i < pens.Count; i++)
     143              pens[i].Dispose();
    144144          } else {
    145145            {
     
    170170      }
    171171
    172       for (int i = 0; i < pens.Length; i++)
    173         pens[i].Dispose();
    174 
    175172      flowPen.Dispose();
    176173    }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/CVRPTWView.cs

    r6851 r7858  
    3131      DoubleArray readyTime = Content.ReadyTime;
    3232
    33       Pen[] pens = {new Pen(Color.FromArgb(92,20,237)), new Pen(Color.FromArgb(237,183,20)), new Pen(Color.FromArgb(237,20,219)), new Pen(Color.FromArgb(20,237,76)),
    34                     new Pen(Color.FromArgb(237,61,20)), new Pen(Color.FromArgb(115,78,26)), new Pen(Color.FromArgb(20,237,229)), new Pen(Color.FromArgb(39,101,19)),
    35                     new Pen(Color.FromArgb(230,170,229)), new Pen(Color.FromArgb(142,136,89)), new Pen(Color.FromArgb(157,217,166)), new Pen(Color.FromArgb(31,19,101)),
    36                     new Pen(Color.FromArgb(173,237,20)), new Pen(Color.FromArgb(230,231,161)), new Pen(Color.FromArgb(142,89,89)), new Pen(Color.FromArgb(93,89,142)),
    37                     new Pen(Color.FromArgb(146,203,217)), new Pen(Color.FromArgb(101,19,75)), new Pen(Color.FromArgb(198,20,237)), new Pen(Color.FromArgb(185,185,185)),
    38                     new Pen(Color.FromArgb(179,32,32)), new Pen(Color.FromArgb(18,119,115)), new Pen(Color.FromArgb(104,158,239)), new Pen(Color.Black)};
    39 
    4033      if ((coordinates != null) && (coordinates.Rows > 0) && (coordinates.Columns == 2)) {
    4134        double xMin = double.MaxValue, yMin = double.MaxValue, xMax = double.MinValue, yMax = double.MinValue;
     
    5447          if (Solution != null) {
    5548            int currentTour = 0;
    56             foreach (Tour tour in Solution.GetTours()) {
     49
     50            List<Tour> tours = Solution.GetTours();
     51            List<Pen> pens = GetColors(tours.Count);
     52
     53            foreach (Tour tour in tours) {
    5754              double t = 0.0;
    5855              Point[] tourPoints = new Point[tour.Stops.Count + 2];
     
    9188              }
    9289
    93               graphics.DrawPolygon(pens[((currentTour >= pens.Length) ? (pens.Length - 1) : (currentTour))], tourPoints);
     90              graphics.DrawPolygon(pens[currentTour], tourPoints);
    9491
    9592              for (int i = 0; i < tour.Stops.Count; i++) {
     
    10198              currentTour++;
    10299            }
     100
     101            for (int i = 0; i < pens.Count; i++)
     102              pens[i].Dispose();
    103103          } else {
    104104            Point locationPoint;
     
    117117        }
    118118      }
    119 
    120       for (int i = 0; i < pens.Length; i++)
    121         pens[i].Dispose();
    122119    }
    123120  }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/MDCVRPPDTWView.cs

    r6947 r7858  
    4646      int cities = Content.Cities.Value;
    4747
    48       Pen[] pens = {new Pen(Color.FromArgb(92,20,237)), new Pen(Color.FromArgb(237,183,20)), new Pen(Color.FromArgb(237,20,219)), new Pen(Color.FromArgb(20,237,76)),
    49                     new Pen(Color.FromArgb(237,61,20)), new Pen(Color.FromArgb(115,78,26)), new Pen(Color.FromArgb(20,237,229)), new Pen(Color.FromArgb(39,101,19)),
    50                     new Pen(Color.FromArgb(230,170,229)), new Pen(Color.FromArgb(142,136,89)), new Pen(Color.FromArgb(157,217,166)), new Pen(Color.FromArgb(31,19,101)),
    51                     new Pen(Color.FromArgb(173,237,20)), new Pen(Color.FromArgb(230,231,161)), new Pen(Color.FromArgb(142,89,89)), new Pen(Color.FromArgb(93,89,142)),
    52                     new Pen(Color.FromArgb(146,203,217)), new Pen(Color.FromArgb(101,19,75)), new Pen(Color.FromArgb(198,20,237)), new Pen(Color.FromArgb(185,185,185)),
    53                     new Pen(Color.FromArgb(179,32,32)), new Pen(Color.FromArgb(18,119,115)), new Pen(Color.FromArgb(104,158,239)), new Pen(Color.Black)};
    54 
    5548      Pen flowPen = new Pen(Brushes.Red, 3);
    5649      flowPen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
     
    7972
    8073            int currentTour = 0;
    81             foreach (Tour tour in Solution.GetTours()) {
     74
     75            List<Tour> tours = Solution.GetTours();
     76            List<Pen> pens = GetColors(tours.Count);
     77
     78            foreach (Tour tour in tours) {
    8279              int tourIndex = Solution.GetTourIndex(tour);
    8380              int vehicle = Solution.GetVehicleAssignment(tourIndex);
     
    148145
    149146              if (!drawFlow)
    150                 graphics.DrawPolygon(pens[((currentTour >= pens.Length) ? (pens.Length - 1) : (currentTour))], tourPoints);
     147                graphics.DrawPolygon(pens[currentTour], tourPoints);
    151148
    152149              for (int i = 0; i < tour.Stops.Count; i++) {
     
    168165              currentTour++;
    169166            }
     167
     168            for (int i = 0; i < pens.Count; i++)
     169              pens[i].Dispose();
    170170          } else {
    171171            {
     
    197197      }
    198198
    199       for (int i = 0; i < pens.Length; i++)
    200         pens[i].Dispose();
    201 
    202199      flowPen.Dispose();
    203200    }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/MDCVRPTWView.cs

    r6854 r7858  
    3434      int depots = Content.Depots.Value;
    3535
    36       Pen[] pens = {new Pen(Color.FromArgb(92,20,237)), new Pen(Color.FromArgb(237,183,20)), new Pen(Color.FromArgb(237,20,219)), new Pen(Color.FromArgb(20,237,76)),
    37                     new Pen(Color.FromArgb(237,61,20)), new Pen(Color.FromArgb(115,78,26)), new Pen(Color.FromArgb(20,237,229)), new Pen(Color.FromArgb(39,101,19)),
    38                     new Pen(Color.FromArgb(230,170,229)), new Pen(Color.FromArgb(142,136,89)), new Pen(Color.FromArgb(157,217,166)), new Pen(Color.FromArgb(31,19,101)),
    39                     new Pen(Color.FromArgb(173,237,20)), new Pen(Color.FromArgb(230,231,161)), new Pen(Color.FromArgb(142,89,89)), new Pen(Color.FromArgb(93,89,142)),
    40                     new Pen(Color.FromArgb(146,203,217)), new Pen(Color.FromArgb(101,19,75)), new Pen(Color.FromArgb(198,20,237)), new Pen(Color.FromArgb(185,185,185)),
    41                     new Pen(Color.FromArgb(179,32,32)), new Pen(Color.FromArgb(18,119,115)), new Pen(Color.FromArgb(104,158,239)), new Pen(Color.Black)};
    42 
    4336      if ((coordinates != null) && (coordinates.Rows > 0) && (coordinates.Columns == 2)) {
    4437        double xMin = double.MaxValue, yMin = double.MaxValue, xMax = double.MinValue, yMax = double.MinValue;
     
    6356
    6457            int currentTour = 0;
    65             foreach (Tour tour in Solution.GetTours()) {
     58
     59            List<Tour> tours = Solution.GetTours();
     60            List<Pen> pens = GetColors(tours.Count);
     61
     62            foreach (Tour tour in tours) {
    6663              int tourIndex = Solution.GetTourIndex(tour);
    6764              int vehicle = Solution.GetVehicleAssignment(tourIndex);
     
    116113              }
    117114
    118               graphics.DrawPolygon(pens[((currentTour >= pens.Length) ? (pens.Length - 1) : (currentTour))], tourPoints);
     115              graphics.DrawPolygon(pens[currentTour], tourPoints);
    119116
    120117              for (int i = 0; i < tour.Stops.Count; i++) {
     
    126123              currentTour++;
    127124            }
     125
     126            for (int i = 0; i < pens.Count; i++)
     127              pens[i].Dispose();
    128128          } else {
    129129            Point locationPoint;
     
    144144        }
    145145      }
    146 
    147       for (int i = 0; i < pens.Length; i++)
    148         pens[i].Dispose();
    149146    }
    150147  }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/MultiDepotVRPView.cs

    r6851 r7858  
    2828      BoolValue useDistanceMatrix = Content.UseDistanceMatrix;
    2929
    30       Pen[] pens = {new Pen(Color.FromArgb(92,20,237)), new Pen(Color.FromArgb(237,183,20)), new Pen(Color.FromArgb(237,20,219)), new Pen(Color.FromArgb(20,237,76)),
    31                     new Pen(Color.FromArgb(237,61,20)), new Pen(Color.FromArgb(115,78,26)), new Pen(Color.FromArgb(20,237,229)), new Pen(Color.FromArgb(39,101,19)),
    32                     new Pen(Color.FromArgb(230,170,229)), new Pen(Color.FromArgb(142,136,89)), new Pen(Color.FromArgb(157,217,166)), new Pen(Color.FromArgb(31,19,101)),
    33                     new Pen(Color.FromArgb(173,237,20)), new Pen(Color.FromArgb(230,231,161)), new Pen(Color.FromArgb(142,89,89)), new Pen(Color.FromArgb(93,89,142)),
    34                     new Pen(Color.FromArgb(146,203,217)), new Pen(Color.FromArgb(101,19,75)), new Pen(Color.FromArgb(198,20,237)), new Pen(Color.FromArgb(185,185,185)),
    35                     new Pen(Color.FromArgb(179,32,32)), new Pen(Color.FromArgb(18,119,115)), new Pen(Color.FromArgb(104,158,239)), new Pen(Color.Black)};
    36 
    37 
    3830      if ((coordinates != null) && (coordinates.Rows > 0) && (coordinates.Columns == 2)) {
    3931        double xMin = double.MaxValue, yMin = double.MaxValue, xMax = double.MinValue, yMax = double.MinValue;
     
    5850
    5951            int currentTour = 0;
    60             foreach (Tour tour in Solution.GetTours()) {
     52
     53            List<Tour> tours = Solution.GetTours();
     54            List<Pen> pens = GetColors(tours.Count);
     55
     56            foreach (Tour tour in tours) {
    6157              Point[] tourPoints = new Point[tour.Stops.Count + 2];
    6258              Brush[] customerBrushes = new Brush[tour.Stops.Count];
     
    9389              }
    9490
    95               graphics.DrawPolygon(pens[((currentTour >= pens.Length) ? (pens.Length - 1) : (currentTour))], tourPoints);
     91              graphics.DrawPolygon(pens[currentTour], tourPoints);
    9692
    9793              for (int i = 0; i < tour.Stops.Count; i++) {
     
    10399              currentTour++;
    104100            }
     101
     102            for (int i = 0; i < pens.Count; i++)
     103              pens[i].Dispose();
    105104          } else {
    106105            Point locationPoint;
     
    121120        }
    122121      }
    123 
    124       for (int i = 0; i < pens.Length; i++)
    125         pens[i].Dispose();
    126122    }
    127123  }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/SingleDepotVRPView.cs

    r4374 r7858  
    2828      BoolValue useDistanceMatrix = Content.UseDistanceMatrix;
    2929
    30       Pen[] pens = {new Pen(Color.FromArgb(92,20,237)), new Pen(Color.FromArgb(237,183,20)), new Pen(Color.FromArgb(237,20,219)), new Pen(Color.FromArgb(20,237,76)),
    31                     new Pen(Color.FromArgb(237,61,20)), new Pen(Color.FromArgb(115,78,26)), new Pen(Color.FromArgb(20,237,229)), new Pen(Color.FromArgb(39,101,19)),
    32                     new Pen(Color.FromArgb(230,170,229)), new Pen(Color.FromArgb(142,136,89)), new Pen(Color.FromArgb(157,217,166)), new Pen(Color.FromArgb(31,19,101)),
    33                     new Pen(Color.FromArgb(173,237,20)), new Pen(Color.FromArgb(230,231,161)), new Pen(Color.FromArgb(142,89,89)), new Pen(Color.FromArgb(93,89,142)),
    34                     new Pen(Color.FromArgb(146,203,217)), new Pen(Color.FromArgb(101,19,75)), new Pen(Color.FromArgb(198,20,237)), new Pen(Color.FromArgb(185,185,185)),
    35                     new Pen(Color.FromArgb(179,32,32)), new Pen(Color.FromArgb(18,119,115)), new Pen(Color.FromArgb(104,158,239)), new Pen(Color.Black)};
    36 
    37 
    3830      if ((coordinates != null) && (coordinates.Rows > 0) && (coordinates.Columns == 2)) {
    3931        double xMin = double.MaxValue, yMin = double.MaxValue, xMax = double.MinValue, yMax = double.MinValue;
     
    5143        using (Graphics graphics = Graphics.FromImage(bitmap)) {
    5244          if (Solution != null) {
     45             List<Tour> tours = Solution.GetTours();
     46             List<Pen> pens = GetColors(tours.Count);
     47
    5348            int currentTour = 0;
    54             foreach (Tour tour in Solution.GetTours()) {
     49            foreach (Tour tour in tours) {
    5550              Point[] tourPoints = new Point[tour.Stops.Count + 2];
    5651              Brush[] customerBrushes = new Brush[tour.Stops.Count];
     
    7671              }
    7772
    78               graphics.DrawPolygon(pens[((currentTour >= pens.Length) ? (pens.Length - 1) : (currentTour))], tourPoints);
     73              graphics.DrawPolygon(pens[currentTour], tourPoints);
    7974
    8075              for (int i = 0; i < tour.Stops.Count; i++) {
     
    8681              currentTour++;
    8782            }
     83
     84            for (int i = 0; i < pens.Count; i++)
     85               pens[i].Dispose();
    8886          } else {
    8987            Point locationPoint;
     
    102100        }
    103101      }
    104 
    105       for (int i = 0; i < pens.Length; i++)
    106         pens[i].Dispose();
    107102    }
    108103  }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/VRPProblemInstanceView.cs

    r6715 r7858  
    7474    protected abstract void DrawVisualization(Bitmap bitmap);
    7575
     76    protected List<Pen> GetColors(int count) {
     77      List<Pen> result = new List<Pen>();
     78
     79      int i = 0;
     80
     81      int r = 255;
     82      int g = 255;
     83      int b = 255;
     84
     85      int step = Math.Max(1, 200 * 6 / count);
     86
     87      while (result.Count != count) {
     88        switch (i) {
     89          case 0: result.Add(new Pen(Color.FromArgb(0, 0, b)));
     90            break;
     91          case 1: result.Add(new Pen(Color.FromArgb(0, g, 0)));
     92            break;
     93          case 2: result.Add(new Pen(Color.FromArgb(r, 0, 0)));
     94            break;
     95          case 3: result.Add(new Pen(Color.FromArgb(0, g, b)));
     96            break;
     97          case 4: result.Add(new Pen(Color.FromArgb(r, 0, b)));
     98            break;
     99          case 5: result.Add(new Pen(Color.FromArgb(r, g, 0)));
     100            break;
     101        }
     102       
     103        i++;
     104        if (i == 6) {
     105          i = 0;
     106
     107          if(r >= step)
     108            r -= step;
     109
     110          if(g >= step)
     111           g -= step;
     112
     113          if(b >= step)
     114           b -= step;
     115        }       
     116      }
     117
     118      return result;
     119    }
     120
    76121    protected void GenerateImage() {
    77122      if ((pictureBox.Width > 0) && (pictureBox.Height > 0)) {
Note: See TracChangeset for help on using the changeset viewer.