Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1106


Ignore:
Timestamp:
01/09/09 18:05:03 (16 years ago)
Author:
gkronber
Message:

worked on presentation layer for CEDMA. Added a results view that displays data in a simple DataGrid. (#419)

Location:
branches/CEDMA-Refactoring-Ticket419
Files:
7 added
9 edited
3 moved

Legend:

Unmodified
Added
Removed
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Charting/BubbleChart.cs

    r573 r1106  
    2727using HeuristicLab.Charting;
    2828using System.Windows.Forms;
     29using HeuristicLab.CEDMA.Core;
    2930
    3031namespace HeuristicLab.CEDMA.Charting {
     
    5051    private double maxY = double.NegativeInfinity;
    5152    private List<Record> records;
    52     private ResultList results;
     53    private Results results;
    5354    private Dictionary<IPrimitive, Record> primitiveToRecordDictionary;
    5455    private Dictionary<Record, IPrimitive> recordToPrimitiveDictionary;
     
    5657    private Group points;
    5758
    58     public BubbleChart(ResultList results, PointD lowerLeft, PointD upperRight)
     59    public BubbleChart(Results results, PointD lowerLeft, PointD upperRight)
    5960      : base(lowerLeft, upperRight) {
    6061      records = new List<Record>();
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Charting/HeuristicLab.CEDMA.Charting.csproj

    r1075 r1106  
    6666  </ItemGroup>
    6767  <ItemGroup>
    68     <Compile Include="BubbleChart.cs" />
    69     <Compile Include="BubbleChartControl.cs">
    70       <SubType>UserControl</SubType>
    71     </Compile>
    72     <Compile Include="BubbleChartControl.Designer.cs">
    73       <DependentUpon>BubbleChartControl.cs</DependentUpon>
    74     </Compile>
    75     <Compile Include="Histogram.cs" />
    76     <Compile Include="HistogramControl.cs">
    77       <SubType>UserControl</SubType>
    78     </Compile>
    79     <Compile Include="HistogramControl.Designer.cs">
    80       <DependentUpon>HistogramControl.cs</DependentUpon>
    81     </Compile>
    82     <Compile Include="ModelView.cs">
    83       <SubType>UserControl</SubType>
    84     </Compile>
    85     <Compile Include="ModelView.Designer.cs">
    86       <DependentUpon>ModelView.cs</DependentUpon>
    87     </Compile>
    8868    <Compile Include="HeuristicLabCedmaChartingPlugin.cs" />
    8969    <Compile Include="Properties\AssemblyInfo.cs" />
    9070  </ItemGroup>
    9171  <ItemGroup>
     72    <ProjectReference Include="..\HeuristicLab.CEDMA.Core\HeuristicLab.CEDMA.Core.csproj">
     73      <Project>{C27DDF6C-84DF-45EF-B82F-57A28DD51166}</Project>
     74      <Name>HeuristicLab.CEDMA.Core</Name>
     75    </ProjectReference>
    9276    <ProjectReference Include="..\HeuristicLab.CEDMA.DB.Interfaces\HeuristicLab.CEDMA.DB.Interfaces.csproj">
    9377      <Project>{4F9BB789-D561-436B-B226-2BF44B7D0804}</Project>
     
    135119    <None Include="Properties\AssemblyInfo.frame" />
    136120  </ItemGroup>
    137   <ItemGroup>
    138     <EmbeddedResource Include="BubbleChartControl.resx">
    139       <DependentUpon>BubbleChartControl.cs</DependentUpon>
    140       <SubType>Designer</SubType>
    141     </EmbeddedResource>
    142     <EmbeddedResource Include="HistogramControl.resx">
    143       <DependentUpon>HistogramControl.cs</DependentUpon>
    144       <SubType>Designer</SubType>
    145     </EmbeddedResource>
    146     <EmbeddedResource Include="ModelView.resx">
    147       <DependentUpon>ModelView.cs</DependentUpon>
    148       <SubType>Designer</SubType>
    149     </EmbeddedResource>
    150   </ItemGroup>
    151121  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    152122  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/Console.cs

    r957 r1106  
    2929using System.ServiceModel.Description;
    3030using HeuristicLab.CEDMA.DB.Interfaces;
    31 using HeuristicLab.CEDMA.Charting;
    3231
    3332namespace HeuristicLab.CEDMA.Core {
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSet.cs

    r1073 r1106  
    8888      Results results = new Results(Store);
    8989      results.FilterDataSet(new Entity(Ontology.CedmaNameSpace + Guid));
     90      return results;
    9091    }
    9192  }
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetView.Designer.cs

    r1073 r1106  
    7575      // resultsButton
    7676      //
     77      this.resultsButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    7778      this.resultsButton.Location = new System.Drawing.Point(84, 128);
    7879      this.resultsButton.Name = "resultsButton";
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetView.cs

    r1075 r1106  
    6464    private void resultsButton_Click(object sender, EventArgs e) {
    6565      Results results = dataSet.GetResults();
    66       IControl resultsControl = (IControl)results.CreateView();
     66      IControl resultsControl = new ResultsViewContainer(results);
    6767      PluginManager.ControlManager.ShowControl(resultsControl);
    6868    }
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/HeuristicLab.CEDMA.Core.csproj

    r1075 r1106  
    7272  </ItemGroup>
    7373  <ItemGroup>
     74    <Compile Include="TableResultsView.cs">
     75      <SubType>UserControl</SubType>
     76    </Compile>
     77    <Compile Include="TableResultsView.Designer.cs">
     78      <DependentUpon>TableResultsView.cs</DependentUpon>
     79    </Compile>
    7480    <Compile Include="Console.cs" />
    7581    <Compile Include="ConsoleEditor.cs">
    7682      <SubType>UserControl</SubType>
    7783    </Compile>
     84    <Compile Include="IResultsView.cs" />
    7885    <Compile Include="Problem.cs" />
    7986    <Compile Include="DataSet.cs" />
     
    101108    <Compile Include="ProblemInjector.cs" />
    102109    <Compile Include="Results.cs" />
    103     <Compile Include="ResultsView.cs">
     110    <Compile Include="ResultsViewContainer.cs">
    104111      <SubType>UserControl</SubType>
    105112    </Compile>
    106     <Compile Include="ResultsView.Designer.cs">
    107       <DependentUpon>ResultsView.cs</DependentUpon>
     113    <Compile Include="ResultsViewContainer.Designer.cs">
     114      <DependentUpon>ResultsViewContainer.cs</DependentUpon>
    108115    </Compile>
    109116  </ItemGroup>
     
    112119  </ItemGroup>
    113120  <ItemGroup>
    114     <ProjectReference Include="..\HeuristicLab.CEDMA.Charting\HeuristicLab.CEDMA.Charting.csproj">
    115       <Project>{1BF17271-5350-476A-8F6D-FC74FA3E82CA}</Project>
    116       <Name>HeuristicLab.CEDMA.Charting</Name>
    117     </ProjectReference>
    118121    <ProjectReference Include="..\HeuristicLab.CEDMA.DB.Interfaces\HeuristicLab.CEDMA.DB.Interfaces.csproj">
    119122      <Project>{4F9BB789-D561-436B-B226-2BF44B7D0804}</Project>
     
    142145  </ItemGroup>
    143146  <ItemGroup>
     147    <EmbeddedResource Include="TableResultsView.resx">
     148      <DependentUpon>TableResultsView.cs</DependentUpon>
     149    </EmbeddedResource>
    144150    <EmbeddedResource Include="ConsoleEditor.resx">
    145151      <DependentUpon>ConsoleEditor.cs</DependentUpon>
     
    155161      <DependentUpon>ProblemView.cs</DependentUpon>
    156162    </EmbeddedResource>
    157     <EmbeddedResource Include="ResultsView.resx">
    158       <DependentUpon>ResultsView.cs</DependentUpon>
     163    <EmbeddedResource Include="ResultsViewContainer.resx">
     164      <DependentUpon>ResultsViewContainer.cs</DependentUpon>
    159165    </EmbeddedResource>
    160166  </ItemGroup>
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/Results.cs

    r1075 r1106  
    3636
    3737namespace HeuristicLab.CEDMA.Core {
    38   public class Results : IViewable, IEnumerable<Record> {
    39     private Dictionary<Record, Dataset> datasets;
     38  public class Results {
     39    public static string[] CategoricalVariables {
     40      get { return new string[] { "TargetVariable" }; }
     41    }
     42
     43    public static string[] OrdinalVariables {
     44      get { return new string[] { "ValidationMeanAbsolutePercentageError" }; }
     45    }
    4046
    4147    private IStore store;
     
    4753    }
    4854
    49     private void ReloadList() {
    50       var results = store.Select(new Statement(Ontology.AnyEntity, Ontology.PredicateInstanceOf, Ontology.TypeGeneticProgrammingFunctionTree))
    51       .Select(x => store.Select(new SelectFilter(
    52         new Entity[] { new Entity(x.Subject.Uri) },
    53         new Entity[] { Ontology.PredicateModelAttribute },
    54           new Resource[] { Ontology.AnyEntity })));
     55    private Entity dataSetEntity;
     56
     57    public Results(IStore store) {
     58      this.store = store;
     59    }
     60
     61    internal void FilterDataSet(Entity entity) {
     62      this.dataSetEntity = entity;
     63    }
     64
     65    internal IEnumerable<object[]> SelectRows(List<string> columnNames) {
     66      if (store == null) yield return null;
     67
     68      Resource[] columnNamesRes = columnNames.Select(x => new Literal(x)).ToArray();
     69
     70      var results = store.Select(new Statement(dataSetEntity, Ontology.PredicateHasModel, Ontology.AnyEntity))
     71         .SelectMany(x => store.Select(new SelectFilter(
     72           new Entity[] { (Entity)x.Property },
     73           new Entity[] { Ontology.PredicateModelAttribute },
     74           new Resource[] { Ontology.AnyEntity })))
     75         .SelectMany(x =>
     76           store.Select(
     77              new SelectFilter(
     78              new Entity[] { (Entity)x.Property },
     79              new Entity[] { Ontology.PredicateModelAttributeName },
     80              columnNamesRes)).Select(y =>
     81                new {
     82                  Model = x.Subject,
     83                  Attribute = (Entity)x.Property,
     84                  AttributeName = (Literal)y.Property
     85                }))
     86         .SelectMany(x =>
     87           store.Select(
     88             new Statement(x.Attribute, Ontology.PredicateModelAttributeValue, Ontology.AnyEntity))
     89             .Select(y =>
     90               new {
     91                 Model = x.Model.Uri,
     92                 AttributeName = x.AttributeName.Value,
     93                 AttributeValue = ((Literal)y.Property).Value
     94               })).GroupBy(x=>x.Model);
     95
    5596
    5697      Random random = new Random();
    57       foreach(Statement[] ss in results) {
    58         if(ss.Length > 0) {
    59           Record r = new Record(this, ss[0].Subject.Uri);
    60           r.Set(Record.X_JITTER, random.NextDouble() * 2.0 - 1.0);
    61           r.Set(Record.Y_JITTER, random.NextDouble() * 2.0 - 1.0);
    62           foreach(Statement s in ss) {
    63             string varName;
    64             predicateToVariableName.TryGetValue(s.Predicate, out varName);
    65             if(varName != null) {
    66               if(varName == Record.TREE_HEIGHT || varName == Record.TREE_SIZE || varName == Record.TARGET_VARIABLE) {
    67                 r.Set(varName, (double)(int)((Literal)s.Property).Value);
    68               } else {
    69                 r.Set(varName, (double)((Literal)s.Property).Value);
    70               }
    71             }
    72           }
    73           lock(records) {
    74             records.Add(r);
    75           }
    76           FireRecordAdded(r);
    77         }
     98      foreach (var row in results) {
     99
     100        yield return row.Select(x => x.AttributeValue).ToArray();
     101        //if (ss.Length > 0) {
     102        //  Record r = new Record(this, ss[0].Subject.Uri);
     103        //  r.Set(Record.X_JITTER, random.NextDouble() * 2.0 - 1.0);
     104        //  r.Set(Record.Y_JITTER, random.NextDouble() * 2.0 - 1.0);
     105        //  foreach (Statement s in ss) {
     106        //    string varName;
     107        //    predicateToVariableName.TryGetValue(s.Predicate, out varName);
     108        //    if (varName != null) {
     109        //      if (varName == Record.TREE_HEIGHT || varName == Record.TREE_SIZE || varName == Record.TARGET_VARIABLE) {
     110        //        r.Set(varName, (double)(int)((Literal)s.Property).Value);
     111        //      } else {
     112        //        r.Set(varName, (double)((Literal)s.Property).Value);
     113        //      }
     114        //    }
     115        //  }
     116        //}
    78117      }
    79       FireChanged();
    80118    }
    81 
    82     public Results(IStore store)
    83       : base() {
    84       this.store = store;
    85       records = new List<Record>();
    86       datasets = new Dictionary<Record, Dataset>();
    87       //predicateToVariableName = new Dictionary<Entity, string>();
    88       //predicateToVariableName[targetVariablePredicate] = Record.TARGET_VARIABLE;
    89       //predicateToVariableName[treeSizePredicate] = Record.TREE_SIZE;
    90       //predicateToVariableName[treeHeightPredicate] = Record.TREE_HEIGHT;
    91       //predicateToVariableName[selectionPressurePredicate] = Record.SELECTIONPRESSURE;
    92       //predicateToVariableName[trainingMAPEPredicate] = Record.MAPE_TRAINING;
    93       //predicateToVariableName[validationMAPEPredicate] = Record.MAPE_VALIDATION;
    94       //predicateToVariableName[testMAPEPredicate] = Record.MAPE_TEST;
    95       //predicateToVariableName[trainingR2Predicate] = Record.R2_TRAINING;
    96       //predicateToVariableName[validationR2Predicate] = Record.R2_VALIDATION;
    97       //predicateToVariableName[testR2Predicate] = Record.R2_TEST;
    98     }
    99 
    100     public override IView CreateView() {
    101       return new ResultsView(this);
    102     }
    103 
    104     //internal void OpenModel(Record record) {
    105     //  IList<Statement> modelResults = store.Select(new Statement(new Entity(record.Uri), Ontology.PredicateSerializedData, Ontology.AnyEntity));
    106     //  if(modelResults.Count == 1) {
    107     //    string rawData = ((SerializedLiteral)modelResults[0].Property).RawData;
    108     //    XmlDocument doc = new XmlDocument();
    109     //    doc.LoadXml(rawData);
    110     //    IFunctionTree tree = (IFunctionTree)PersistenceManager.Restore(doc.ChildNodes[1], new Dictionary<Guid, IStorable>());
    111     //    int targetVariable = (int)record.Get(Record.TARGET_VARIABLE);
    112     //    Dataset dataset = GetDataset(record);
    113 
    114     //    ModelView modelView = new ModelView(record, dataset, tree, targetVariable);
    115     //    PluginManager.ControlManager.ShowControl(modelView);
    116     //  }
    117     //}
    118 
    119     //private Dataset GetDataset(Record record) {
    120     //  if(!datasets.ContainsKey(record)) {
    121     //    IList<Statement> result = store.Select(new Statement(Ontology.AnyEntity, Ontology.PredicateHasModel, new Entity(record.Uri)));
    122     //    if(result.Count == 1) {
    123     //      IList<Statement> datasetResult = store.Select(new Statement(result[0].Subject, Ontology.PredicateSerializedData, Ontology.AnyEntity));
    124     //      if(datasetResult.Count == 1) {
    125     //        string rawData = ((SerializedLiteral)datasetResult[0].Property).RawData;
    126     //        XmlDocument doc = new XmlDocument();
    127     //        doc.LoadXml(rawData);
    128     //        Dataset dataset = (Dataset)PersistenceManager.Restore(doc.ChildNodes[1], new Dictionary<Guid, IStorable>());
    129     //        datasets.Add(record, dataset);
    130     //      }
    131     //    }
    132     //  }
    133     //  return datasets[record];
    134     //}
    135 
    136     //internal void OpenAlgorithm(Record record) {
    137     //  IList<Statement> generatedBy = store.Select(new Statement(new Entity(record.Uri), Ontology.PredicateGeneratedBy, Ontology.AnyEntity));
    138     //  if(generatedBy.Count == 1) {
    139     //    IList<Statement> algoResult = store.Select(new Statement((Entity)generatedBy[0].Property, Ontology.PredicateSerializedData, Ontology.AnyEntity));
    140     //    if(algoResult.Count == 1) {
    141     //      string rawData = ((SerializedLiteral)algoResult[0].Property).RawData;
    142     //      XmlDocument doc = new XmlDocument();
    143     //      doc.LoadXml(rawData);
    144     //      IItem algo = (IItem)PersistenceManager.Restore(doc.ChildNodes[1], new Dictionary<Guid, IStorable>());
    145     //      PluginManager.ControlManager.ShowControl(algo.CreateView());
    146     //    }
    147     //  }
    148     //}
    149 
    150     internal void FilterDataSet(Entity entity) {
    151 
    152     }
    153 
    154     #region IEnumerable<Record> Members
    155 
    156     public IEnumerator<Record> GetEnumerator() {
    157       throw new NotImplementedException();
    158     }
    159 
    160     #endregion
    161 
    162     #region IEnumerable Members
    163 
    164     IEnumerator IEnumerable.GetEnumerator() {
    165       return this.GetEnumerator();
    166     }
    167 
    168     #endregion
    169119  }
    170120}
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/ResultsViewContainer.Designer.cs

    r1103 r1106  
    11namespace HeuristicLab.CEDMA.Core {
    2   partial class ResultsView {
     2  partial class ResultsViewContainer {
    33    /// <summary>
    44    /// Required designer variable.
     
    2424    /// </summary>
    2525    private void InitializeComponent() {
    26       this.yJitterLabel = new System.Windows.Forms.Label();
    27       this.xJitterlabel = new System.Windows.Forms.Label();
    28       this.xTrackBar = new System.Windows.Forms.TrackBar();
    29       this.xAxisLabel = new System.Windows.Forms.Label();
    30       this.xAxisComboBox = new System.Windows.Forms.ComboBox();
    31       this.yAxisLabel = new System.Windows.Forms.Label();
    32       this.yAxisComboBox = new System.Windows.Forms.ComboBox();
    33       this.yTrackBar = new System.Windows.Forms.TrackBar();
    34       this.sizeComboBox = new System.Windows.Forms.ComboBox();
    35       this.sizeLabel = new System.Windows.Forms.Label();
    36       this.invertCheckbox = new System.Windows.Forms.CheckBox();
    37       this.chartPanel = new System.Windows.Forms.Panel();
    38       ((System.ComponentModel.ISupportInitialize)(this.xTrackBar)).BeginInit();
    39       ((System.ComponentModel.ISupportInitialize)(this.yTrackBar)).BeginInit();
     26      this.viewComboBox = new System.Windows.Forms.ComboBox();
     27      this.showButton = new System.Windows.Forms.Button();
     28      this.viewPanel = new System.Windows.Forms.Panel();
    4029      this.SuspendLayout();
    4130      //
    42       // yJitterLabel
     31      // viewComboBox
    4332      //
    44       this.yJitterLabel.AutoSize = true;
    45       this.yJitterLabel.Location = new System.Drawing.Point(3, 30);
    46       this.yJitterLabel.Name = "yJitterLabel";
    47       this.yJitterLabel.Size = new System.Drawing.Size(29, 13);
    48       this.yJitterLabel.TabIndex = 13;
    49       this.yJitterLabel.Text = "jitter:";
     33      this.viewComboBox.FormattingEnabled = true;
     34      this.viewComboBox.Location = new System.Drawing.Point(3, 3);
     35      this.viewComboBox.Name = "viewComboBox";
     36      this.viewComboBox.Size = new System.Drawing.Size(121, 21);
     37      this.viewComboBox.TabIndex = 1;
     38      this.viewComboBox.SelectedValueChanged += new System.EventHandler(this.viewComboBox_SelectedValueChanged);
    5039      //
    51       // xJitterlabel
     40      // showButton
    5241      //
    53       this.xJitterlabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    54       this.xJitterlabel.AutoSize = true;
    55       this.xJitterlabel.Location = new System.Drawing.Point(291, 418);
    56       this.xJitterlabel.Name = "xJitterlabel";
    57       this.xJitterlabel.Size = new System.Drawing.Size(29, 13);
    58       this.xJitterlabel.TabIndex = 12;
    59       this.xJitterlabel.Text = "jitter:";
     42      this.showButton.Location = new System.Drawing.Point(130, 3);
     43      this.showButton.Name = "showButton";
     44      this.showButton.Size = new System.Drawing.Size(75, 23);
     45      this.showButton.TabIndex = 2;
     46      this.showButton.Text = "Show";
     47      this.showButton.UseVisualStyleBackColor = true;
     48      this.showButton.Click += new System.EventHandler(this.showButton_Click);
    6049      //
    61       // xTrackBar
     50      // viewPanel
    6251      //
    63       this.xTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    64       this.xTrackBar.Location = new System.Drawing.Point(326, 418);
    65       this.xTrackBar.Maximum = 100;
    66       this.xTrackBar.Name = "xTrackBar";
    67       this.xTrackBar.Size = new System.Drawing.Size(121, 45);
    68       this.xTrackBar.TabIndex = 11;
    69       this.xTrackBar.TickStyle = System.Windows.Forms.TickStyle.None;
    70       this.xTrackBar.ValueChanged += new System.EventHandler(this.jitterTrackBar_ValueChanged);
    71       //
    72       // xAxisLabel
    73       //
    74       this.xAxisLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    75       this.xAxisLabel.AutoSize = true;
    76       this.xAxisLabel.Location = new System.Drawing.Point(305, 394);
    77       this.xAxisLabel.Name = "xAxisLabel";
    78       this.xAxisLabel.Size = new System.Drawing.Size(15, 13);
    79       this.xAxisLabel.TabIndex = 8;
    80       this.xAxisLabel.Text = "x:";
    81       //
    82       // xAxisComboBox
    83       //
    84       this.xAxisComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    85       this.xAxisComboBox.FormattingEnabled = true;
    86       this.xAxisComboBox.Location = new System.Drawing.Point(326, 391);
    87       this.xAxisComboBox.Name = "xAxisComboBox";
    88       this.xAxisComboBox.Size = new System.Drawing.Size(121, 21);
    89       this.xAxisComboBox.TabIndex = 7;
    90       this.xAxisComboBox.SelectedIndexChanged += new System.EventHandler(this.xAxisComboBox_SelectedIndexChanged);
    91       //
    92       // yAxisLabel
    93       //
    94       this.yAxisLabel.AutoSize = true;
    95       this.yAxisLabel.Location = new System.Drawing.Point(3, 6);
    96       this.yAxisLabel.Name = "yAxisLabel";
    97       this.yAxisLabel.Size = new System.Drawing.Size(15, 13);
    98       this.yAxisLabel.TabIndex = 6;
    99       this.yAxisLabel.Text = "y:";
    100       //
    101       // yAxisComboBox
    102       //
    103       this.yAxisComboBox.FormattingEnabled = true;
    104       this.yAxisComboBox.Location = new System.Drawing.Point(24, 3);
    105       this.yAxisComboBox.Name = "yAxisComboBox";
    106       this.yAxisComboBox.Size = new System.Drawing.Size(121, 21);
    107       this.yAxisComboBox.TabIndex = 5;
    108       this.yAxisComboBox.SelectedIndexChanged += new System.EventHandler(this.yAxisComboBox_SelectedIndexChanged);
    109       //
    110       // yTrackBar
    111       //
    112       this.yTrackBar.Location = new System.Drawing.Point(38, 30);
    113       this.yTrackBar.Maximum = 100;
    114       this.yTrackBar.Name = "yTrackBar";
    115       this.yTrackBar.Size = new System.Drawing.Size(107, 45);
    116       this.yTrackBar.TabIndex = 10;
    117       this.yTrackBar.TickStyle = System.Windows.Forms.TickStyle.None;
    118       this.yTrackBar.ValueChanged += new System.EventHandler(this.jitterTrackBar_ValueChanged);
    119       //
    120       // sizeComboBox
    121       //
    122       this.sizeComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    123       this.sizeComboBox.FormattingEnabled = true;
    124       this.sizeComboBox.Location = new System.Drawing.Point(329, 3);
    125       this.sizeComboBox.Name = "sizeComboBox";
    126       this.sizeComboBox.Size = new System.Drawing.Size(121, 21);
    127       this.sizeComboBox.TabIndex = 14;
    128       this.sizeComboBox.SelectedIndexChanged += new System.EventHandler(this.sizeComboBox_SelectedIndexChanged);
    129       //
    130       // sizeLabel
    131       //
    132       this.sizeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    133       this.sizeLabel.AutoSize = true;
    134       this.sizeLabel.Location = new System.Drawing.Point(259, 6);
    135       this.sizeLabel.Name = "sizeLabel";
    136       this.sizeLabel.Size = new System.Drawing.Size(64, 13);
    137       this.sizeLabel.TabIndex = 15;
    138       this.sizeLabel.Text = "Bubble size:";
    139       //
    140       // invertCheckbox
    141       //
    142       this.invertCheckbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    143       this.invertCheckbox.AutoSize = true;
    144       this.invertCheckbox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
    145       this.invertCheckbox.Location = new System.Drawing.Point(326, 30);
    146       this.invertCheckbox.Name = "invertCheckbox";
    147       this.invertCheckbox.Size = new System.Drawing.Size(64, 17);
    148       this.invertCheckbox.TabIndex = 16;
    149       this.invertCheckbox.Text = "Inverse:";
    150       this.invertCheckbox.UseVisualStyleBackColor = true;
    151       this.invertCheckbox.CheckedChanged += new System.EventHandler(this.sizeComboBox_SelectedIndexChanged);
    152       //
    153       // chartPanel
    154       //
    155       this.chartPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     52      this.viewPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    15653                  | System.Windows.Forms.AnchorStyles.Left)
    15754                  | System.Windows.Forms.AnchorStyles.Right)));
    158       this.chartPanel.Location = new System.Drawing.Point(0, 81);
    159       this.chartPanel.Name = "chartPanel";
    160       this.chartPanel.Size = new System.Drawing.Size(447, 304);
    161       this.chartPanel.TabIndex = 17;
     55      this.viewPanel.Location = new System.Drawing.Point(4, 32);
     56      this.viewPanel.Name = "viewPanel";
     57      this.viewPanel.Size = new System.Drawing.Size(443, 424);
     58      this.viewPanel.TabIndex = 4;
    16259      //
    163       // ResultListView
     60      // ResultsViewContainer
    16461      //
    16562      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    16663      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    167       this.Controls.Add(this.chartPanel);
    168       this.Controls.Add(this.invertCheckbox);
    169       this.Controls.Add(this.sizeLabel);
    170       this.Controls.Add(this.sizeComboBox);
    171       this.Controls.Add(this.yJitterLabel);
    172       this.Controls.Add(this.xJitterlabel);
    173       this.Controls.Add(this.xTrackBar);
    174       this.Controls.Add(this.xAxisLabel);
    175       this.Controls.Add(this.xAxisComboBox);
    176       this.Controls.Add(this.yAxisLabel);
    177       this.Controls.Add(this.yAxisComboBox);
    178       this.Controls.Add(this.yTrackBar);
    179       this.Name = "ResultListView";
     64      this.Controls.Add(this.viewPanel);
     65      this.Controls.Add(this.showButton);
     66      this.Controls.Add(this.viewComboBox);
     67      this.Name = "ResultsViewContainer";
    18068      this.Size = new System.Drawing.Size(450, 459);
    181       ((System.ComponentModel.ISupportInitialize)(this.xTrackBar)).EndInit();
    182       ((System.ComponentModel.ISupportInitialize)(this.yTrackBar)).EndInit();
    18369      this.ResumeLayout(false);
    184       this.PerformLayout();
    18570
    18671    }
     
    18873    #endregion
    18974
    190     private System.Windows.Forms.Label xAxisLabel;
    191     private System.Windows.Forms.ComboBox xAxisComboBox;
    192     private System.Windows.Forms.Label yAxisLabel;
    193     private System.Windows.Forms.ComboBox yAxisComboBox;
    194     private System.Windows.Forms.TrackBar yTrackBar;
    195     private System.Windows.Forms.TrackBar xTrackBar;
    196     private System.Windows.Forms.Label xJitterlabel;
    197     private System.Windows.Forms.Label yJitterLabel;
    198     private System.Windows.Forms.ComboBox sizeComboBox;
    199     private System.Windows.Forms.Label sizeLabel;
    200     private System.Windows.Forms.CheckBox invertCheckbox;
    201     private System.Windows.Forms.Panel chartPanel;
     75    private System.Windows.Forms.ComboBox viewComboBox;
     76    private System.Windows.Forms.Button showButton;
     77    private System.Windows.Forms.Panel viewPanel;
     78
    20279  }
    20380}
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/ResultsViewContainer.cs

    r1103 r1106  
    88using System.Windows.Forms;
    99using HeuristicLab.Core;
    10 using HeuristicLab.CEDMA.Charting;
     10using HeuristicLab.PluginInfrastructure;
    1111
    1212namespace HeuristicLab.CEDMA.Core {
    13   public partial class ResultsView : ViewBase {
     13  public partial class ResultsViewContainer : ViewBase {
    1414    private Results results;
    15     private const string FREQUENCY = "<Frequency>";
    16     private const string CONSTANT_SIZE = "<constant>";
    17     private BubbleChartControl bubbleChartControl;
    18     private HistogramControl histogramControl;
    19     private Label pleaseSelectAxisLabel = new Label();
    2015
    21     public ResultsView(Results results) {
     16    public ResultsViewContainer(Results results) {
    2217      this.results = results;
    2318      InitializeComponent();
    24       InitCharts();
    25       xAxisComboBox.Items.AddRange(results.VariableNames);
    26       yAxisComboBox.Items.Add(FREQUENCY);
    27       yAxisComboBox.Items.AddRange(results.VariableNames);
    28       sizeComboBox.Items.Add(CONSTANT_SIZE);
    29       sizeComboBox.Items.AddRange(results.VariableNames);
    30       sizeComboBox.SelectedItem = sizeComboBox.Items[0];
    31       sizeComboBox.Enabled = false;
    32       invertCheckbox.Enabled = false;
    33       sizeLabel.Enabled = false;
    34       yAxisComboBox.SelectedItem = yAxisComboBox.Items[0];
    35       xAxisComboBox.SelectedItem = xAxisComboBox.Items[0];
     19      PopulateViewComboBox();
     20      showButton.Enabled = false;
    3621    }
    3722
    38     private void InitCharts() {
    39       bubbleChartControl = new BubbleChartControl();
    40       bubbleChartControl.Chart = new BubbleChart(results, 0, 0, 100, 100);
    41       histogramControl = new HistogramControl();
    42       histogramControl.Chart = new Histogram(results, 0, 0, 100, 100);
     23    private void PopulateViewComboBox() {
     24      DiscoveryService service = new DiscoveryService();
     25      Type[] viewTypes = service.GetTypes(typeof(IResultsView));
     26      foreach (Type t in viewTypes)
     27        viewComboBox.Items.Add(t);
    4328    }
    4429
    45     private void yAxisComboBox_SelectedIndexChanged(object sender, EventArgs e) {
    46       UpdateChart();
    47     }
    48 
    49     private void xAxisComboBox_SelectedIndexChanged(object sender, EventArgs e) {
    50       UpdateChart();
    51     }
    52 
    53     private void UpdateChart() {
    54       if(xAxisComboBox.SelectedItem == null || yAxisComboBox.SelectedItem == null) return;
    55       if(yAxisComboBox.SelectedItem.Equals(FREQUENCY)) {
    56         xJitterlabel.Enabled = false;
    57         xTrackBar.Enabled = false;
    58         yJitterLabel.Enabled = false;
    59         yTrackBar.Enabled = false;
    60         sizeComboBox.Enabled = false;
    61         invertCheckbox.Enabled = false;
    62         sizeLabel.Enabled = false;
    63         chartPanel.Controls.Clear();
    64         chartPanel.Controls.Add(histogramControl);
    65         histogramControl.Chart.ShowFrequency((string)xAxisComboBox.SelectedItem);
    66         histogramControl.Dock = DockStyle.Fill;
    67       } else {
    68         xJitterlabel.Enabled = true;
    69         xTrackBar.Enabled = true;
    70         yJitterLabel.Enabled = true;
    71         yTrackBar.Enabled = true;
    72         sizeComboBox.Enabled = true;
    73         invertCheckbox.Enabled = true;
    74         sizeLabel.Enabled = true;
    75         chartPanel.Controls.Clear();
    76         chartPanel.Controls.Add(bubbleChartControl);
    77         bubbleChartControl.Chart.ShowXvsY((string)xAxisComboBox.SelectedItem, (string)yAxisComboBox.SelectedItem);
    78         bubbleChartControl.Dock = DockStyle.Fill;
     30    private void showButton_Click(object sender, EventArgs e) {
     31      viewPanel.Controls.Clear();
     32      try {
     33        Type type = (Type)viewComboBox.SelectedItem;
     34        IResultsView view = (IResultsView)Activator.CreateInstance(type);
     35        Control control = view.Control;
     36        viewPanel.Controls.Add(control);
     37        control.Dock = DockStyle.Fill;
     38        view.ShowResults(results);
     39      }
     40      catch (Exception ex) {
     41        Label errorLabel = new Label();
     42        errorLabel.Text = "Couldn't load selected view: " + viewComboBox.SelectedItem + "\n" + ex.Message;
     43        viewPanel.Controls.Add(errorLabel);
     44        errorLabel.Dock = DockStyle.Fill;
    7945      }
    8046    }
    8147
    82     private void jitterTrackBar_ValueChanged(object sender, EventArgs e) {
    83       if(bubbleChartControl.Chart != null) {
    84         double xJitterFactor = xTrackBar.Value / 100.0;
    85         double yJitterFactor = yTrackBar.Value / 100.0;
    86         bubbleChartControl.Chart.SetJitter(xJitterFactor, yJitterFactor);
    87       }
    88       UpdateChart();
    89     }
    90 
    91     private void sizeComboBox_SelectedIndexChanged(object sender, EventArgs e) {
    92       if(bubbleChartControl.Chart != null) {
    93         bubbleChartControl.Chart.SetBubbleSizeDimension((string)sizeComboBox.SelectedItem, invertCheckbox.Checked);
    94         UpdateChart();
    95       }
     48    private void viewComboBox_SelectedValueChanged(object sender, EventArgs e) {
     49      showButton.Enabled = viewComboBox.SelectedItem != null;
    9650    }
    9751  }
  • branches/CEDMA-Refactoring-Ticket419/HeuristicLab.sln

    r1105 r1106  
    733733    {1F5FA590-1D2D-406C-BDBD-03BAECEA3C80}.Visualization Debug|x86.Build.0 = Debug|x86
    734734    {1F1CF3ED-374C-4288-995B-93F6B872F571}.CEDMA Debug|Any CPU.ActiveCfg = Debug|x86
    735     {1F1CF3ED-374C-4288-995B-93F6B872F571}.CEDMA Debug|Any CPU.Build.0 = Debug|x86
    736735    {1F1CF3ED-374C-4288-995B-93F6B872F571}.CEDMA Debug|x86.ActiveCfg = Debug|x86
    737736    {1F1CF3ED-374C-4288-995B-93F6B872F571}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     
    747746    {1F1CF3ED-374C-4288-995B-93F6B872F571}.Visualization Debug|x86.Build.0 = Debug|x86
    748747    {74223A32-C726-4978-BE78-37113A18373C}.CEDMA Debug|Any CPU.ActiveCfg = Debug|x86
    749     {74223A32-C726-4978-BE78-37113A18373C}.CEDMA Debug|Any CPU.Build.0 = Debug|x86
    750748    {74223A32-C726-4978-BE78-37113A18373C}.CEDMA Debug|x86.ActiveCfg = Debug|x86
    751749    {74223A32-C726-4978-BE78-37113A18373C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     
    761759    {74223A32-C726-4978-BE78-37113A18373C}.Visualization Debug|x86.Build.0 = Debug|x86
    762760    {7C20D100-8BEB-433A-9499-F075E2CB9297}.CEDMA Debug|Any CPU.ActiveCfg = Debug|x86
    763     {7C20D100-8BEB-433A-9499-F075E2CB9297}.CEDMA Debug|Any CPU.Build.0 = Debug|x86
    764761    {7C20D100-8BEB-433A-9499-F075E2CB9297}.CEDMA Debug|x86.ActiveCfg = Debug|x86
    765762    {7C20D100-8BEB-433A-9499-F075E2CB9297}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     
    775772    {7C20D100-8BEB-433A-9499-F075E2CB9297}.Visualization Debug|x86.Build.0 = Debug|x86
    776773    {6084CFB5-733F-449D-9F92-2E40D13F0514}.CEDMA Debug|Any CPU.ActiveCfg = Debug|x86
    777     {6084CFB5-733F-449D-9F92-2E40D13F0514}.CEDMA Debug|Any CPU.Build.0 = Debug|x86
    778774    {6084CFB5-733F-449D-9F92-2E40D13F0514}.CEDMA Debug|x86.ActiveCfg = Debug|x86
    779775    {6084CFB5-733F-449D-9F92-2E40D13F0514}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Note: See TracChangeset for help on using the changeset viewer.