Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4870


Ignore:
Timestamp:
11/20/10 02:44:45 (14 years ago)
Author:
swagner
Message:

Added axis labels for data tables (#925)

Location:
trunk/sources
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Analysis.Views/3.3/DataTableView.cs

    r4849 r4870  
    6767      foreach (DataRow row in Content.Rows)
    6868        DeregisterDataRowEvents(row);
     69      Content.VisualPropertiesChanged -= new EventHandler(Content_VisualPropertiesChanged);
    6970      Content.Rows.ItemsAdded -= new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsAdded);
    7071      Content.Rows.ItemsRemoved -= new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsRemoved);
     
    8081    protected override void RegisterContentEvents() {
    8182      base.RegisterContentEvents();
     83      Content.VisualPropertiesChanged += new EventHandler(Content_VisualPropertiesChanged);
    8284      Content.Rows.ItemsAdded += new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsAdded);
    8385      Content.Rows.ItemsRemoved += new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsRemoved);
     
    9294      invisibleSeries.Clear();
    9395      chart.Titles[0].Text = string.Empty;
     96      chart.ChartAreas[0].AxisX.Title = string.Empty;
     97      chart.ChartAreas[0].AxisY.Title = string.Empty;
     98      chart.ChartAreas[0].AxisY2.Title = string.Empty;
    9499      chart.Series.Clear();
    95100      if (Content != null) {
     
    97102        foreach (DataRow row in Content.Rows)
    98103          AddDataRow(row);
     104        chart.ChartAreas[0].AxisX.Title = Content.VisualProperties.XAxisTitle;
     105        chart.ChartAreas[0].AxisY.Title = Content.VisualProperties.YAxisTitle;
     106        chart.ChartAreas[0].AxisY2.Title = Content.VisualProperties.SecondYAxisTitle;
    99107      }
    100108    }
     
    188196      }
    189197    }
     198    private void Content_VisualPropertiesChanged(object sender, EventArgs e) {
     199      if (InvokeRequired)
     200        Invoke(new EventHandler(Content_VisualPropertiesChanged), sender, e);
     201      else {
     202        chart.ChartAreas[0].AxisX.Title = Content.VisualProperties.XAxisTitle;
     203        chart.ChartAreas[0].AxisY.Title = Content.VisualProperties.YAxisTitle;
     204        chart.ChartAreas[0].AxisY2.Title = Content.VisualProperties.SecondYAxisTitle;
     205      }
     206    }
    190207    private void Rows_ItemsAdded(object sender, CollectionItemsChangedEventArgs<DataRow> e) {
    191208      if (InvokeRequired)
  • trunk/sources/HeuristicLab.Analysis/3.3/AlleleFrequencyAnalyzer.cs

    r4849 r4870  
    172172        if (!results.ContainsKey("Alleles")) {
    173173          allelesTable = new DataTable("Alleles");
    174           results.Add(new Result("Alleles", allelesTable));
     174          allelesTable.VisualProperties.XAxisTitle = "Iteration";
     175          allelesTable.VisualProperties.YAxisTitle = "Number of Alleles";
     176          allelesTable.VisualProperties.SecondYAxisTitle = "Number of Alleles";
    175177
    176178          allelesTable.Rows.Add(new DataRow("Unique Alleles"));
     
    192194          allelesTable.Rows["Lost Alleles of Best Known Solution"].VisualProperties.SecondYAxis = true;
    193195          allelesTable.Rows["Lost Alleles of Best Known Solution"].VisualProperties.StartIndexZero = true;
     196
     197          results.Add(new Result("Alleles", allelesTable));
    194198        } else {
    195199          allelesTable = (DataTable)results["Alleles"].Value;
  • trunk/sources/HeuristicLab.Analysis/3.3/DataRowVisualProperties.cs

    r4777 r4870  
    119119      startIndexZero = false;
    120120    }
    121     public DataRowVisualProperties(DataRowChartType chartType, bool secondYAxis, Color color, bool startIndexZero) {
    122       this.chartType = chartType;
    123       this.secondYAxis = secondYAxis;
    124       this.color = color;
    125       this.startIndexZero = startIndexZero;
    126     }
    127121
    128122    public override IDeepCloneable Clone(Cloner cloner) {
  • trunk/sources/HeuristicLab.Analysis/3.3/DataTable.cs

    r4774 r4870  
    2222using System;
    2323using System.Collections.Generic;
     24using System.ComponentModel;
    2425using System.Drawing;
    2526using System.Linq;
     
    4142    }
    4243
    43     [Storable]
     44    private DataTableVisualProperties visualProperties;
     45    public DataTableVisualProperties VisualProperties {
     46      get { return visualProperties; }
     47      set {
     48        if (visualProperties != value) {
     49          if (value == null) throw new ArgumentNullException("VisualProperties");
     50          if (visualProperties != null) visualProperties.PropertyChanged -= new PropertyChangedEventHandler(VisualProperties_PropertyChanged);
     51          visualProperties = value;
     52          visualProperties.PropertyChanged += new PropertyChangedEventHandler(VisualProperties_PropertyChanged);
     53          OnVisualPropertiesChanged();
     54        }
     55      }
     56    }
     57
    4458    private NamedItemCollection<DataRow> rows;
    4559    public NamedItemCollection<DataRow> Rows {
     
    4761    }
    4862
    49     #region Storing & Cloning
     63    #region Persistence Properties
     64    [Storable(Name = "VisualProperties")]
     65    private DataTableVisualProperties StorableVisualProperties {
     66      get { return VisualProperties; }
     67      set { VisualProperties = value; }
     68    }
     69    [Storable(Name = "rows")]
     70    private IEnumerable<DataRow> StorableRows {
     71      get { return rows; }
     72      set { rows = new NamedItemCollection<DataRow>(value); }
     73    }
     74    #endregion
     75
    5076    [StorableConstructor]
    5177    private DataTable(bool deserializing) : base(deserializing) { }
    5278    private DataTable(DataTable original, Cloner cloner)
    5379      : base(original, cloner) {
     80      this.VisualProperties = (DataTableVisualProperties)cloner.Clone(original.visualProperties);
    5481      this.rows = cloner.Clone(original.rows);
    5582      this.RegisterRowsEvents();
    5683    }
     84    public DataTable()
     85      : base() {
     86      VisualProperties = new DataTableVisualProperties();
     87      rows = new NamedItemCollection<DataRow>();
     88      this.RegisterRowsEvents();
     89    }
     90    public DataTable(string name)
     91      : base(name) {
     92      VisualProperties = new DataTableVisualProperties();
     93      rows = new NamedItemCollection<DataRow>();
     94      this.RegisterRowsEvents();
     95    }
     96    public DataTable(string name, string description)
     97      : base(name, description) {
     98      VisualProperties = new DataTableVisualProperties();
     99      rows = new NamedItemCollection<DataRow>();
     100      this.RegisterRowsEvents();
     101    }
     102
     103    // BackwardsCompatibility3.3
     104    #region Backwards compatible code, remove with 3.4
     105    [StorableHook(HookType.AfterDeserialization)]
     106    private void AfterDeserialization() {
     107      if (VisualProperties == null) VisualProperties = new DataTableVisualProperties();
     108    }
     109    #endregion
     110
    57111    public override IDeepCloneable Clone(Cloner cloner) {
    58112      return new DataTable(this, cloner);
    59113    }
    60     #endregion
    61     public DataTable()
    62       : base() {
    63       rows = new NamedItemCollection<DataRow>();
    64       this.RegisterRowsEvents();
    65     }
    66     public DataTable(string name)
    67       : base(name) {
    68       rows = new NamedItemCollection<DataRow>();
    69       this.RegisterRowsEvents();
    70     }
    71     public DataTable(string name, string description)
    72       : base(name, description) {
    73       rows = new NamedItemCollection<DataRow>();
    74       this.RegisterRowsEvents();
     114
     115    public event EventHandler VisualPropertiesChanged;
     116    private void OnVisualPropertiesChanged() {
     117      EventHandler handler = VisualPropertiesChanged;
     118      if (handler != null) handler(this, EventArgs.Empty);
     119    }
     120
     121    private void VisualProperties_PropertyChanged(object sender, PropertyChangedEventArgs e) {
     122      OnVisualPropertiesChanged();
    75123    }
    76124
  • trunk/sources/HeuristicLab.Analysis/3.3/HeuristicLab.Analysis-3.3.csproj

    r4703 r4870  
    118118    <Compile Include="Allele.cs" />
    119119    <Compile Include="AlleleFrequency.cs" />
     120    <Compile Include="DataTableVisualProperties.cs" />
    120121    <Compile Include="DataTableHistory.cs" />
    121122    <Compile Include="HeatMapHistory.cs" />
  • trunk/sources/HeuristicLab.Analysis/3.3/PopulationDiversityAnalyzer.cs

    r4862 r4870  
    186186          if (!results.ContainsKey("Average Minimum/Average/Maximum Solution Similarity")) {
    187187            minAvgMaxSimilarityDataTable = new DataTable("Average Minimum/Average/Maximum Solution Similarity");
    188             results.Add(new Result("Average Minimum/Average/Maximum Solution Similarity", minAvgMaxSimilarityDataTable));
     188            minAvgMaxSimilarityDataTable.VisualProperties.XAxisTitle = "Iteration";
     189            minAvgMaxSimilarityDataTable.VisualProperties.YAxisTitle = "Solution Similarity";
    189190            minAvgMaxSimilarityDataTable.Rows.Add(new DataRow("Average Minimum Solution Similarity", null));
    190191            minAvgMaxSimilarityDataTable.Rows["Average Minimum Solution Similarity"].VisualProperties.StartIndexZero = true;
     
    193194            minAvgMaxSimilarityDataTable.Rows.Add(new DataRow("Average Maximum Solution Similarity", null));
    194195            minAvgMaxSimilarityDataTable.Rows["Average Maximum Solution Similarity"].VisualProperties.StartIndexZero = true;
     196            results.Add(new Result("Average Minimum/Average/Maximum Solution Similarity", minAvgMaxSimilarityDataTable));
    195197          } else {
    196198            minAvgMaxSimilarityDataTable = (DataTable)results["Average Minimum/Average/Maximum Solution Similarity"].Value;
     
    202204          // store minimum, average, maximum similarities data table
    203205          DataTable minAvgMaxSimilaritiesDataTable = new DataTable("Minimum/Average/Maximum Solution Similarities");
     206          minAvgMaxSimilaritiesDataTable.VisualProperties.XAxisTitle = "Solution Index";
     207          minAvgMaxSimilaritiesDataTable.VisualProperties.YAxisTitle = "Solution Similarity";
    204208          minAvgMaxSimilaritiesDataTable.Rows.Add(new DataRow("Minimum Solution Similarity", null, minSimilarities));
    205209          minAvgMaxSimilaritiesDataTable.Rows["Minimum Solution Similarity"].VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Points;
Note: See TracChangeset for help on using the changeset viewer.