Changeset 9973


Ignore:
Timestamp:
09/16/13 18:52:52 (6 years ago)
Author:
gkronber
Message:

#2102 moved "shrink data analysis solutions" and "create ensemble" to a "data analysis" sub-menu in the "Edit" menu. And added an export button to the views for data analysis solution that automatically discovers supported exporters.

Location:
trunk/sources
Files:
2 added
10 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/SymbolicClassificationSolutionView.Designer.cs

    r9456 r9973  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SymbolicDiscriminantFunctionClassificationSolutionView));
    4847      this.btnSimplify = new System.Windows.Forms.Button();
    4948      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
     
    5453      this.detailsGroupBox.SuspendLayout();
    5554      this.SuspendLayout();
     55      exportButton.Visible = false;
    5656      //
    5757      // splitContainer
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/SymbolicDiscriminantFunctionClassificationSolutionView.Designer.cs

    r9456 r9973  
    5454      this.detailsGroupBox.SuspendLayout();
    5555      this.SuspendLayout();
     56      exportButton.Visible = false;
    5657      //
    5758      // splitContainer
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionView.Designer.cs

    r9456 r9973  
    6060      //
    6161      this.splitContainer.Panel1.Controls.Add(this.btnSimplify);
    62       this.splitContainer.Size = new System.Drawing.Size(480, 275);
    63       this.splitContainer.SplitterDistance = 255;
    64       //
    65       // itemsGroupBox
    66       //
    67       this.itemsGroupBox.Size = new System.Drawing.Size(486, 294);
    68       //
    69       // itemsListView
    70       //
    71       this.itemsListView.Size = new System.Drawing.Size(249, 238);
    72       //
    73       // detailsGroupBox
    74       //
    75       this.detailsGroupBox.Size = new System.Drawing.Size(215, 246);
    7662      //
    7763      // addButton
     
    8369      this.toolTip.SetToolTip(this.removeButton, "Remove");
    8470      //
    85       // viewHost
    86       //
    87       this.viewHost.Size = new System.Drawing.Size(203, 221);
    88       //
    8971      // btnSimplify
    9072      //
    9173      this.btnSimplify.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    92       this.btnSimplify.Location = new System.Drawing.Point(177, 4);
     74      this.btnSimplify.Location = new System.Drawing.Point(172, 4);
    9375      this.btnSimplify.Name = "btnSimplify";
    9476      this.btnSimplify.Size = new System.Drawing.Size(75, 23);
     
    10082      // SymbolicRegressionSolutionView
    10183      //
    102       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    10384      this.Name = "SymbolicRegressionSolutionView";
    10485      this.Size = new System.Drawing.Size(486, 294);
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis.Views/3.4/SymbolicTimeSeriesPrognosisSolutionView.Designer.cs

    r9456 r9973  
    5454      this.SuspendLayout();
    5555      //
     56      // exportButton
     57      //
     58      this.exportButton.Visible = false;
     59      //
    5660      // splitContainer
    5761      //
     
    6064      //
    6165      this.splitContainer.Panel1.Controls.Add(this.btnSimplify);
    62       this.splitContainer.Size = new System.Drawing.Size(480, 275);
    63       this.splitContainer.SplitterDistance = 255;
    64       //
    65       // itemsGroupBox
    66       //
    67       this.itemsGroupBox.Size = new System.Drawing.Size(486, 294);
    68       //
    69       // itemsListView
    70       //
    71       this.itemsListView.Size = new System.Drawing.Size(249, 238);
    72       //
    73       // detailsGroupBox
    74       //
    75       this.detailsGroupBox.Size = new System.Drawing.Size(215, 246);
    7666      //
    7767      // addButton
     
    8373      this.toolTip.SetToolTip(this.removeButton, "Remove");
    8474      //
    85       // viewHost
    86       //
    87       this.viewHost.Size = new System.Drawing.Size(203, 221);
    88       //
    8975      // btnSimplify
    9076      //
    9177      this.btnSimplify.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    92       this.btnSimplify.Location = new System.Drawing.Point(177, 4);
     78      this.btnSimplify.Location = new System.Drawing.Point(172, 4);
    9379      this.btnSimplify.Name = "btnSimplify";
    9480      this.btnSimplify.Size = new System.Drawing.Size(75, 23);
     
    10086      // SymbolicTimeSeriesPrognosisSolutionView
    10187      //
    102       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    10388      this.Name = "SymbolicTimeSeriesPrognosisSolutionView";
    104       this.Size = new System.Drawing.Size(486, 294);
    10589      this.splitContainer.Panel1.ResumeLayout(false);
    10690      this.splitContainer.Panel2.ResumeLayout(false);
     
    11094      this.detailsGroupBox.ResumeLayout(false);
    11195      this.ResumeLayout(false);
     96
    11297    }
    11398
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Exporters/SymbolicSolutionExcelExporter.cs

    r9937 r9973  
    3434
    3535namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
    36   public class ExportSymbolicSolutionToExcelMenuItem : MainForm.WindowsForms.MenuItem, IOptimizerUserInterfaceItemProvider {
     36  public class SymbolicSolutionExcelExporter : IDataAnalysisSolutionExporter {
    3737    private const string TRAININGSTART = "TrainingStart";
    3838    private const string TRAININGEND = "TrainingEnd";
     
    4040    private const string TESTEND = "TestEnd";
    4141
    42     public override string Name {
    43       get { return "Export Symbolic Solution To Excel"; }
    44     }
    45     public override IEnumerable<string> Structure {
    46       get { return new string[] { "&Data Analysis" }; }
    47     }
    48     public override int Position {
    49       get { return 5200; }
    50     }
    51     public override string ToolTipText {
    52       get { return "Create excel file of symbolic data analysis solutions."; }
    53     }
    54 
    55     protected override void OnToolStripItemSet(EventArgs e) {
    56       base.OnToolStripItemSet(e);
    57       ToolStripItem.Enabled = false;
    58       var menuItem = ToolStripItem.OwnerItem as ToolStripMenuItem;
    59       if (menuItem != null)
    60         menuItem.DropDownOpening += menuItem_DropDownOpening;
    61     }
    62 
    63     private void menuItem_DropDownOpening(object sender, EventArgs e) {
    64       IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView;
    65       Control control = activeView as Control;
    66       activeView = control.GetNestedControls((c) => c.Visible)
    67         .OfType<IContentView>().FirstOrDefault(v => v.Content is ISymbolicDataAnalysisSolution && v.Content is IRegressionSolution);
    68       ToolStripItem.Enabled = activeView != null;
    69     }
    70 
    71     public override void Execute() {
    72       IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView;
    73       Control control = activeView as Control;
    74       activeView = control.GetNestedControls((c) => c.Visible)
    75         .OfType<IContentView>().First(v => v.Content is ISymbolicDataAnalysisSolution && v.Content is IRegressionSolution);
    76       var solution = (ISymbolicDataAnalysisSolution)activeView.Content;
     42
     43    public string FileTypeFilter {
     44      get { return "Excel 2007 file (*.xlsx)|*.xlsx"; }
     45    }
     46    public bool Supports(IDataAnalysisSolution solution) {
     47      return solution is ISymbolicDataAnalysisSolution &&
     48        solution is IRegressionSolution;
     49    }
     50
     51    public void Export(IDataAnalysisSolution solution, string fileName) {
     52      var symbSolution = solution as ISymbolicDataAnalysisSolution;
     53      if (symbSolution == null) throw new NotSupportedException("This solution cannot be exported to Excel");
    7754      var formatter = new SymbolicDataAnalysisExpressionExcelFormatter();
    78       var formula = formatter.Format(solution.Model.SymbolicExpressionTree, solution.ProblemData.Dataset);
    79       control = (Control)activeView;
    80 
    81 
    82       SaveFileDialog saveFileDialog = new SaveFileDialog();
    83       saveFileDialog.Filter = "Excel Workbook|*.xlsx";
    84       saveFileDialog.Title = "Save an Excel File";
    85       if (saveFileDialog.ShowDialog() == DialogResult.OK) {
    86         string fileName = saveFileDialog.FileName;
    87         using (BackgroundWorker bg = new BackgroundWorker()) {
    88           MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(control, "Exportion solution to " + fileName + ".");
    89           bg.DoWork += (b, e) => ExportChart(fileName, solution, formula);
    90           bg.RunWorkerCompleted += (o, e) => MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(control);
    91           bg.RunWorkerAsync();
    92         }
    93       }
     55      var formula = formatter.Format(symbSolution.Model.SymbolicExpressionTree, solution.ProblemData.Dataset);
     56      ExportChart(fileName, symbSolution, formula);
    9457    }
    9558
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj

    r9587 r9973  
    119119  </ItemGroup>
    120120  <ItemGroup>
     121    <Compile Include="Exporters\SymbolicSolutionExcelExporter.cs" />
    121122    <Compile Include="InteractiveSymbolicExpressionTreeChart.cs">
    122123      <SubType>UserControl</SubType>
     
    131132      <DependentUpon>MathSymbolicDataAnalysisModelView.cs</DependentUpon>
    132133    </Compile>
    133     <Compile Include="MenuItems\ExportSymbolicSolutionToExcelMenuItem.cs" />
    134134    <Compile Include="Plugin.cs" />
    135135    <Compile Include="TextualSymbolicDataAnalysisModelView.cs">
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/MenuItems/CreateEnsembleMenuItem.cs

    r9860 r9973  
    3737    }
    3838    public override IEnumerable<string> Structure {
    39       get { return new string[] { "&Data Analysis" }; }
     39      get { return new string[] { "&Edit", "&Data Analysis" }; }
    4040    }
    4141    public override int Position {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/MenuItems/ShrinkDataAnalysisRunsMenuItem.cs

    r9866 r9973  
    4141    }
    4242    public override IEnumerable<string> Structure {
    43       get { return new string[] { "&Data Analysis" }; }
     43      get { return new string[] { "&Edit", "&Data Analysis" }; }
    4444    }
    4545    public override int Position {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/DataAnalysisSolutionView.Designer.cs

    r9456 r9973  
    4444    /// </summary>
    4545    private void InitializeComponent() {
     46      this.exportButton = new System.Windows.Forms.Button();
     47      this.exportFileDialog = new System.Windows.Forms.SaveFileDialog();
    4648      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    4749      this.splitContainer.Panel1.SuspendLayout();
     
    5456      // splitContainer
    5557      //
     58      //
     59      // splitContainer.Panel2
     60      //
     61      this.splitContainer.Panel2.Controls.Add(this.exportButton);
    5662      //
    5763      // itemsGroupBox
     
    6773      this.toolTip.SetToolTip(this.removeButton, "Remove");
    6874      //
     75      // exportButton
     76      //
     77      this.exportButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     78      this.exportButton.Location = new System.Drawing.Point(215, 4);
     79      this.exportButton.Name = "exportButton";
     80      this.exportButton.Size = new System.Drawing.Size(54, 23);
     81      this.exportButton.TabIndex = 6;
     82      this.exportButton.Text = "Export";
     83      this.exportButton.UseVisualStyleBackColor = true;
     84      this.exportButton.Click += new System.EventHandler(this.exportButton_Click);
     85      //
    6986      // DataAnalysisSolutionView
    7087      //
    71       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    7288      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    7389      this.Name = "DataAnalysisSolutionView";
     
    84100    #endregion
    85101
     102    private System.Windows.Forms.SaveFileDialog exportFileDialog;
     103    protected System.Windows.Forms.Button exportButton;
     104
    86105  }
    87106}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/DataAnalysisSolutionView.cs

    r9456 r9973  
    2222using System;
    2323using System.Collections.Generic;
     24using System.ComponentModel;
    2425using System.Drawing;
    2526using System.Linq;
     
    3031using HeuristicLab.Optimization;
    3132using HeuristicLab.Optimization.Views;
     33using HeuristicLab.PluginInfrastructure;
    3234
    3335namespace HeuristicLab.Problems.DataAnalysis.Views {
     36
    3437  [View("DataAnalysisSolution View")]
    3538  [Content(typeof(DataAnalysisSolution), false)]
    36   public partial class DataAnalysisSolutionView : NamedItemCollectionView<IResult> {
     39  public partial class DataAnalysisSolutionView : Bla {
    3740    public DataAnalysisSolutionView() {
    3841      InitializeComponent();
     
    4952      addButton.Enabled = false;
    5053      removeButton.Enabled = false;
     54      if (Content == null) {
     55        exportButton.Enabled = false;
     56      } else {
     57        exportButton.Enabled = !Locked;
     58      }
    5159    }
    5260
     
    117125      } else
    118126        base.itemsListView_SelectedIndexChanged(sender, e);
     127    }
     128
     129
     130    private void exportButton_Click(object sender, EventArgs e) {
     131      var exporters = ApplicationManager.Manager.GetInstances<IDataAnalysisSolutionExporter>()
     132        .Where(exporter => exporter.Supports(Content)).ToArray();
     133      exportFileDialog.Filter = exporters.Skip(1)
     134        .Aggregate(exporters.First().FileTypeFilter, (s, exporter) => s + "|" + exporter.FileTypeFilter);
     135      var result = exportFileDialog.ShowDialog();
     136      if (result == DialogResult.OK) {
     137
     138        var name = exportFileDialog.FileName;
     139        var selectedExporter = exporters.Single(exporter => exporter.FileTypeFilter == exportFileDialog.Filter);
     140
     141        using (BackgroundWorker bg = new BackgroundWorker()) {
     142          MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Exportion solution to " + name + ".");
     143          bg.DoWork += (_, __) => selectedExporter.Export(Content, name);
     144          bg.RunWorkerCompleted += (_, __) => MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
     145          bg.RunWorkerAsync();
     146        }
     147      }
    119148    }
    120149
     
    190219    #endregion
    191220  }
     221
     222  public class Bla : NamedItemCollectionView<IResult> {
     223
     224  }
     225
    192226}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj

    r9762 r9973  
    148148    </Compile>
    149149    <Compile Include="Interfaces\Classification\IDiscriminantFunctionThresholdCalculator.cs" />
     150    <Compile Include="Interfaces\IDataAnalysisSolutionExporter.cs" />
    150151    <Compile Include="Interfaces\IDependencyCalculator.cs" />
    151152    <Compile Include="Interfaces\Regression\IRegressionEnsembleModel.cs">
Note: See TracChangeset for help on using the changeset viewer.