Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/01/12 14:36:47 (12 years ago)
Author:
gkronber
Message:

#1797: adapted return type of ConstrainedValueParameter properties in FLA branch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/BoxChart/BoxChartCreator.cs

    r7210 r8172  
    22using System.Collections.Generic;
    33using System.Drawing;
    4 using System.Drawing.Drawing2D;
     4using System.Drawing.Imaging;
    55using System.IO;
    66using System.Linq;
    7 using System.Text;
    87using HeuristicLab.Collections;
    98using HeuristicLab.Common;
     
    1413using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    1514using ICSharpCode.SharpZipLib.Zip;
    16 using System.Drawing.Imaging;
    1715
    1816namespace HeuristicLab.Analysis.FitnessLandscape.BoxCharts {
     
    3533    }
    3634    public ValueParameter<IntValue> PaddingParameter {
    37       get { return (ValueParameter<IntValue>) Parameters["Padding"]; }
     35      get { return (ValueParameter<IntValue>)Parameters["Padding"]; }
    3836    }
    3937    public ValueParameter<StringValue> ZipFileNameParameter {
    40       get { return (ValueParameter<StringValue>) Parameters["ZipFileName"]; }
    41     } 
    42     public ConstrainedValueParameter<StringValue> AppendModeParameter {
    43       get { return (ConstrainedValueParameter<StringValue>) Parameters["AppendMode"]; }
    44     } 
     38      get { return (ValueParameter<StringValue>)Parameters["ZipFileName"]; }
     39    }
     40    public IConstrainedValueParameter<StringValue> AppendModeParameter {
     41      get { return (IConstrainedValueParameter<StringValue>)Parameters["AppendMode"]; }
     42    }
    4543    #endregion
    4644
     
    5149    protected int Padding { get { return PaddingParameter.Value.Value; } }
    5250    protected AppendModes AppendMode { get { return (AppendModes)Enum.Parse(typeof(AppendModes), AppendModeParameter.Value.Value); } }
    53       protected List<IBoxChartElementGenerator> Generators {
     51    protected List<IBoxChartElementGenerator> Generators {
    5452      get {
    5553        return ElementsParameter.Value.CheckedItems.Select(i => i.Value).ToList();
     
    6159    [StorableConstructor]
    6260    protected BoxChartCreator(bool deserializing) : base(deserializing) { }
    63     protected BoxChartCreator(BoxChartCreator original, Cloner cloner) : base(original, cloner) {
     61    protected BoxChartCreator(BoxChartCreator original, Cloner cloner)
     62      : base(original, cloner) {
    6463      RegisterEvents();
    6564    }
     
    6766      Parameters.Add(new ValueParameter<StringValue>("ChartName", "The result name of the chart.", new StringValue("Chart")));
    6867      Parameters.Add(new ValueParameter<CheckedItemList<IBoxChartElementGenerator>>("Elements", "List of patient chart element generators.", new CheckedItemList<IBoxChartElementGenerator>()));
    69       Parameters.Add(new ValueParameter<IntValue>("Size", "The size of one box in pixels.", new IntValue(50))); 
    70       Parameters.Add(new ValueParameter<IntValue>("Padding", "The padding inside the boxes", new IntValue(1))); 
     68      Parameters.Add(new ValueParameter<IntValue>("Size", "The size of one box in pixels.", new IntValue(50)));
     69      Parameters.Add(new ValueParameter<IntValue>("Padding", "The padding inside the boxes", new IntValue(1)));
    7170      Parameters.Add(new ValueParameter<StringValue>("ZipFileName", "The name of the zip file that will contain all generated charts.", new StringValue("")));
    7271      Parameters.Add(new ConstrainedValueParameter<StringValue>("AppendMode", "Determines how coordinates of new elements are calculated.",
    73         new ItemSet<StringValue>(Enum.GetNames(typeof (AppendModes)).Select(v => new StringValue(v)))));
     72        new ItemSet<StringValue>(Enum.GetNames(typeof(AppendModes)).Select(v => new StringValue(v)))));
    7473      AppendModeParameter.Value = AppendModeParameter.ValidValues.SingleOrDefault(v => v.Value == AppendModes.Horizontal.ToString());
    7574      RegisterEvents();
     
    8483      if (!Parameters.ContainsKey("AppendMode")) {
    8584        Parameters.Add(new ConstrainedValueParameter<StringValue>("AppendMode", "Determines how coordinates of new elements are calculated.",
    86           new ItemSet<StringValue>(Enum.GetNames(typeof (AppendModes)).Select(v => new StringValue(v)))));
     85          new ItemSet<StringValue>(Enum.GetNames(typeof(AppendModes)).Select(v => new StringValue(v)))));
    8786        AppendModeParameter.Value = AppendModeParameter.ValidValues.SingleOrDefault(v => v.Value == AppendModes.Horizontal.ToString());
    8887      }
     
    109108        var newItems = e.Items.Select(kvp => kvp.Value).ToList();
    110109        switch (AppendMode) {
    111           case AppendModes.Horizontal: 
     110          case AppendModes.Horizontal:
    112111            foreach (var generator in newItems) {
    113112              generator.Y = generators.Max(g => g.Y + g.RowSpan - 1);
     
    132131      var maxX = generators.Max(g => g.X + g.ColSpan);
    133132      var maxY = generators.Max(g => g.Y + g.RowSpan);
    134       for (int i = 0; i<runs.Count; i++) {
     133      for (int i = 0; i < runs.Count; i++) {
    135134        var run = runs[i];
    136         var b = new Bitmap(maxX*Size, maxY*Size);
     135        var b = new Bitmap(maxX * Size, maxY * Size);
    137136        using (var g = Graphics.FromImage(b)) {
    138137          g.FillRectangle(SystemBrushes.Control, 0, 0, b.Width, b.Height);
    139138          foreach (var gen in generators) {
    140             g.SetClip(new Rectangle(gen.X*Size+Padding, gen.Y*Size+Padding, gen.ColSpan*Size-2*Padding, gen.RowSpan*Size-2*Padding));
     139            g.SetClip(new Rectangle(gen.X * Size + Padding, gen.Y * Size + Padding, gen.ColSpan * Size - 2 * Padding, gen.RowSpan * Size - 2 * Padding));
    141140            gen.Draw(run, g);
    142141            g.ResetClip();
Note: See TracChangeset for help on using the changeset viewer.