Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4644


Ignore:
Timestamp:
10/25/10 15:06:21 (14 years ago)
Author:
swagner
Message:

Worked on visual appearance of data rows (#925)

Location:
trunk/sources
Files:
1 added
3 edited

Legend:

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

    r4637 r4644  
    107107    private void AddDataRow(DataRow row) {
    108108      Series series = new Series(row.Name);
    109       series.ChartType = SeriesChartType.FastLine;
     109      switch (row.VisualProperties.ChartType) {
     110        case DataRowVisualProperties.DataRowChartType.Line:
     111          series.ChartType = SeriesChartType.FastLine;
     112          break;
     113        case DataRowVisualProperties.DataRowChartType.Bars:
     114          series.ChartType = SeriesChartType.Bar;
     115          break;
     116        case DataRowVisualProperties.DataRowChartType.Columns:
     117          series.ChartType = SeriesChartType.Column;
     118          break;
     119        case DataRowVisualProperties.DataRowChartType.Points:
     120          series.ChartType = SeriesChartType.FastPoint;
     121          break;
     122        default:
     123          series.ChartType = SeriesChartType.FastPoint;
     124          break;
     125      }
     126      series.YAxisType = row.VisualProperties.SecondYAxis ? AxisType.Secondary : AxisType.Primary;
    110127      series.ToolTip = row.Name + " X = #INDEX, Y = #VAL";
    111128      FillSeriesWithRowValues(series, row);
     
    142159    private void RegisterDataRowEvents(DataRow row) {
    143160      row.NameChanged += new EventHandler(Row_NameChanged);
     161      row.VisualPropertiesChanged += new EventHandler(Row_VisualPropertiesChanged);
    144162      valuesRowsTable.Add(row.Values, row);
    145163      row.Values.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsAdded);
     
    156174      row.Values.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_CollectionReset);
    157175      valuesRowsTable.Remove(row.Values);
     176      row.VisualPropertiesChanged -= new EventHandler(Row_VisualPropertiesChanged);
    158177      row.NameChanged -= new EventHandler(Row_NameChanged);
    159178    }
     
    212231          RegisterDataRowEvents(row);
    213232        }
     233      }
     234    }
     235    private void Row_VisualPropertiesChanged(object sender, EventArgs e) {
     236      if (InvokeRequired)
     237        Invoke(new EventHandler(Row_VisualPropertiesChanged), sender, e);
     238      else {
     239        DataRow row = (DataRow)sender;
     240        switch (row.VisualProperties.ChartType) {
     241          case DataRowVisualProperties.DataRowChartType.Line:
     242            chart.Series[row.Name].ChartType = SeriesChartType.FastLine;
     243            break;
     244          case DataRowVisualProperties.DataRowChartType.Bars:
     245            chart.Series[row.Name].ChartType = SeriesChartType.Bar;
     246            break;
     247          case DataRowVisualProperties.DataRowChartType.Columns:
     248            chart.Series[row.Name].ChartType = SeriesChartType.Column;
     249            break;
     250          case DataRowVisualProperties.DataRowChartType.Points:
     251            chart.Series[row.Name].ChartType = SeriesChartType.FastPoint;
     252            break;
     253          default:
     254            chart.Series[row.Name].ChartType = SeriesChartType.FastPoint;
     255            break;
     256        }
     257        chart.Series[row.Name].YAxisType = row.VisualProperties.SecondYAxis ? AxisType.Secondary : AxisType.Primary;
    214258      }
    215259    }
  • trunk/sources/HeuristicLab.Analysis/3.3/DataRow.cs

    r3431 r4644  
    2020#endregion
    2121
     22using System;
     23using System.Collections.Generic;
     24using System.ComponentModel;
    2225using HeuristicLab.Collections;
    2326using HeuristicLab.Common;
     
    3235  [StorableClass]
    3336  public sealed class DataRow : NamedItem {
    34     [Storable]
     37    private DataRowVisualProperties visualProperties;
     38    public DataRowVisualProperties VisualProperties {
     39      get { return visualProperties; }
     40      set {
     41        if (visualProperties != value) {
     42          if (value == null) throw new ArgumentNullException("VisualProperties");
     43          if (visualProperties != null) visualProperties.PropertyChanged -= new PropertyChangedEventHandler(VisualProperties_PropertyChanged);
     44          visualProperties = value;
     45          visualProperties.PropertyChanged += new PropertyChangedEventHandler(VisualProperties_PropertyChanged);
     46          OnVisualPropertiesChanged();
     47        }
     48      }
     49    }
    3550    private ObservableList<double> values;
    3651    public IObservableList<double> Values {
     
    3853    }
    3954
     55    #region Persistence Properties
     56    [Storable(Name = "VisualProperties")]
     57    private DataRowVisualProperties StorableVisualProperties {
     58      get { return VisualProperties; }
     59      set { VisualProperties = value; }
     60    }
     61    [Storable(Name = "values")]
     62    private IEnumerable<double> StorableValues {
     63      get { return values; }
     64      set { values = new ObservableList<double>(value); }
     65    }
     66    #endregion
     67
    4068    public DataRow()
    4169      : base() {
     70      VisualProperties = new DataRowVisualProperties();
    4271      values = new ObservableList<double>();
    4372    }
    4473    public DataRow(string name)
    4574      : base(name) {
     75      VisualProperties = new DataRowVisualProperties();
    4676      values = new ObservableList<double>();
    4777    }
    4878    public DataRow(string name, string description)
    4979      : base(name, description) {
     80      VisualProperties = new DataRowVisualProperties();
    5081      values = new ObservableList<double>();
    5182    }
     83    public DataRow(string name, string description, DataRowVisualProperties visualProperties)
     84      : base(name, description) {
     85      VisualProperties = visualProperties;
     86      values = new ObservableList<double>();
     87    }
     88    [StorableConstructor]
     89    private DataRow(bool deserializing) { }
     90
     91    // BackwardsCompatibility3.3
     92    #region Backwards compatible code, remove with 3.4
     93    [StorableHook(HookType.AfterDeserialization)]
     94    private void AfterDeserialization() {
     95      if (VisualProperties == null) VisualProperties = new DataRowVisualProperties();
     96    }
     97    #endregion
    5298
    5399    public override IDeepCloneable Clone(Cloner cloner) {
    54100      DataRow clone = new DataRow(Name, Description);
    55101      cloner.RegisterClonedObject(this, clone);
     102      clone.VisualProperties = (DataRowVisualProperties)cloner.Clone(visualProperties);
    56103      clone.values.AddRange(values);
    57104      return clone;
    58105    }
     106
     107    public event EventHandler VisualPropertiesChanged;
     108    private void OnVisualPropertiesChanged() {
     109      EventHandler handler = VisualPropertiesChanged;
     110      if (handler != null) handler(this, EventArgs.Empty);
     111    }
     112
     113    private void VisualProperties_PropertyChanged(object sender, PropertyChangedEventArgs e) {
     114      OnVisualPropertiesChanged();
     115    }
    59116  }
    60117}
  • trunk/sources/HeuristicLab.Analysis/3.3/HeuristicLab.Analysis-3.3.csproj

    r4641 r4644  
    118118    <Compile Include="Allele.cs" />
    119119    <Compile Include="AlleleFrequency.cs" />
     120    <Compile Include="DataRowVisualProperties.cs" />
    120121    <Compile Include="QualityAnalyzer.cs" />
    121122    <Compile Include="MinAverageMaxValueAnalyzer.cs" />
Note: See TracChangeset for help on using the changeset viewer.