Changeset 8172 for branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/BoxChart
- Timestamp:
- 07/01/12 14:36:47 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/BoxChart/BoxChartCreator.cs
r7210 r8172 2 2 using System.Collections.Generic; 3 3 using System.Drawing; 4 using System.Drawing. Drawing2D;4 using System.Drawing.Imaging; 5 5 using System.IO; 6 6 using System.Linq; 7 using System.Text;8 7 using HeuristicLab.Collections; 9 8 using HeuristicLab.Common; … … 14 13 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 15 14 using ICSharpCode.SharpZipLib.Zip; 16 using System.Drawing.Imaging;17 15 18 16 namespace HeuristicLab.Analysis.FitnessLandscape.BoxCharts { … … 35 33 } 36 34 public ValueParameter<IntValue> PaddingParameter { 37 get { return (ValueParameter<IntValue>) 35 get { return (ValueParameter<IntValue>)Parameters["Padding"]; } 38 36 } 39 37 public ValueParameter<StringValue> ZipFileNameParameter { 40 get { return (ValueParameter<StringValue>) 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 } 45 43 #endregion 46 44 … … 51 49 protected int Padding { get { return PaddingParameter.Value.Value; } } 52 50 protected AppendModes AppendMode { get { return (AppendModes)Enum.Parse(typeof(AppendModes), AppendModeParameter.Value.Value); } } 53 51 protected List<IBoxChartElementGenerator> Generators { 54 52 get { 55 53 return ElementsParameter.Value.CheckedItems.Select(i => i.Value).ToList(); … … 61 59 [StorableConstructor] 62 60 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) { 64 63 RegisterEvents(); 65 64 } … … 67 66 Parameters.Add(new ValueParameter<StringValue>("ChartName", "The result name of the chart.", new StringValue("Chart"))); 68 67 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))); 71 70 Parameters.Add(new ValueParameter<StringValue>("ZipFileName", "The name of the zip file that will contain all generated charts.", new StringValue(""))); 72 71 Parameters.Add(new ConstrainedValueParameter<StringValue>("AppendMode", "Determines how coordinates of new elements are calculated.", 73 new ItemSet<StringValue>(Enum.GetNames(typeof 72 new ItemSet<StringValue>(Enum.GetNames(typeof(AppendModes)).Select(v => new StringValue(v))))); 74 73 AppendModeParameter.Value = AppendModeParameter.ValidValues.SingleOrDefault(v => v.Value == AppendModes.Horizontal.ToString()); 75 74 RegisterEvents(); … … 84 83 if (!Parameters.ContainsKey("AppendMode")) { 85 84 Parameters.Add(new ConstrainedValueParameter<StringValue>("AppendMode", "Determines how coordinates of new elements are calculated.", 86 new ItemSet<StringValue>(Enum.GetNames(typeof 85 new ItemSet<StringValue>(Enum.GetNames(typeof(AppendModes)).Select(v => new StringValue(v))))); 87 86 AppendModeParameter.Value = AppendModeParameter.ValidValues.SingleOrDefault(v => v.Value == AppendModes.Horizontal.ToString()); 88 87 } … … 109 108 var newItems = e.Items.Select(kvp => kvp.Value).ToList(); 110 109 switch (AppendMode) { 111 case AppendModes.Horizontal: 110 case AppendModes.Horizontal: 112 111 foreach (var generator in newItems) { 113 112 generator.Y = generators.Max(g => g.Y + g.RowSpan - 1); … … 132 131 var maxX = generators.Max(g => g.X + g.ColSpan); 133 132 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++) { 135 134 var run = runs[i]; 136 var b = new Bitmap(maxX *Size, maxY*Size);135 var b = new Bitmap(maxX * Size, maxY * Size); 137 136 using (var g = Graphics.FromImage(b)) { 138 137 g.FillRectangle(SystemBrushes.Control, 0, 0, b.Width, b.Height); 139 138 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)); 141 140 gen.Draw(run, g); 142 141 g.ResetClip();
Note: See TracChangeset
for help on using the changeset viewer.