Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1350


Ignore:
Timestamp:
03/16/09 19:42:17 (15 years ago)
Author:
mstoeger
Message:

Implemented multiple Y-Axes. A LineChart has several Y-Axes and each Y-Axis has several data rows. The same clipping area is set for all data rows belonging to a Y-Axis. (#433)

Location:
trunk/sources
Files:
2 added
1 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Visualization.Test/LineChartTestForm.cs

    r1249 r1350  
    44
    55namespace HeuristicLab.Visualization.Test {
     6  public delegate void AddValueHandler();
     7
    68  public partial class LineChartTestForm : Form {
    79    private readonly IView view;
     
    2931    }
    3032
     33    public event AddValueHandler AddValue;
     34
    3135    private void btnAddRandomValue_Click(object sender, EventArgs e) {
    32       Random rand = new Random();
     36      if (AddValue != null) {
     37        AddValue();
     38      } else {
     39        Random rand = new Random();
    3340
    34       foreach (IDataRow row in model.Rows)
    35         row.AddValue(rand.NextDouble()*100);
     41        foreach (IDataRow row in model.Rows)
     42          row.AddValue(rand.NextDouble() * 100);
     43      }
    3644    }
    3745  }
  • trunk/sources/HeuristicLab.Visualization.Test/LineChartTests.cs

    r1343 r1350  
    7777      IDataRow row1 = new DataRow();
    7878      IDataRow row2 = new DataRow();
     79      IDataRow row3 = new DataRow();
    7980
    8081      row1.Color = Color.Red;
     
    8889      row2.Label = "Die Grüne";
    8990
     91      row3.Color = Color.Blue;
     92      row3.Thickness = 3;
     93      row3.Style = DrawingStyle.Solid;
     94      row3.Label = "Die Blaue";
     95      row3.YAxis = new YAxisDescriptor();
     96
    9097      model.AddDataRow(row1);
    9198      model.AddDataRow(row2);
     99      model.AddDataRow(row3);
    92100
    93101      Random rand = new Random(42);
    94      
     102
    95103      for (int i = 0; i < 10; i++) {
    96104        row1.AddValue(rand.NextDouble()*10);
    97105        row2.AddValue(rand.NextDouble()*10);
     106        row3.AddValue(rand.NextDouble()*1);
    98107      }
     108
     109      f.AddValue += delegate {
     110        row1.AddValue(rand.NextDouble()*10);
     111        row2.AddValue(rand.NextDouble()*10);
     112        row3.AddValue(rand.NextDouble()*1);
     113      };
    99114
    100115      f.ShowDialog();
     
    114129
    115130
    116       IAggregator aggregator = new MinAggregator();
     131      MinAggregator aggregator = new MinAggregator();
    117132      aggregator.Label = "MinAggregator";
    118133      aggregator.Color = Color.Pink;
     
    173188
    174189
    175         IAggregator aggregator = new MinAggregator();
     190        MinAggregator aggregator = new MinAggregator();
    176191        aggregator.Label = "MinAggregator";
    177192        aggregator.Color = Color.Pink;
     
    182197        model.AddDataRow(aggregator);
    183198
    184         IAggregator maxAggregator = new MaxAggregator();
     199        MaxAggregator maxAggregator = new MaxAggregator();
    185200        maxAggregator.Label = "MaxAggregator";
    186201        maxAggregator.Color = Color.DeepSkyBlue;
     
    192207       
    193208       
    194         IAggregator avgAggregator = new AvgAggregator();
     209        AvgAggregator avgAggregator = new AvgAggregator();
    195210        avgAggregator.Label = "AvgAggregator";
    196211        avgAggregator.Color = Color.Violet;
     
    201216        model.AddDataRow(avgAggregator);
    202217
    203         IAggregator multiAvgAggregator = new AvgAggregator();
     218        AvgAggregator multiAvgAggregator = new AvgAggregator();
    204219        multiAvgAggregator.Label = "MultiAvgAggregator";
    205220        multiAvgAggregator.Color = Color.DarkOliveGreen;
     
    211226        model.AddDataRow(multiAvgAggregator);
    212227
    213         IAggregator multiMaxAggregator = new MaxAggregator();
     228        MaxAggregator multiMaxAggregator = new MaxAggregator();
    214229        multiMaxAggregator.Label = "MultiMaxAggregator";
    215230        multiMaxAggregator.Color = Color.DarkKhaki;
     
    221236        model.AddDataRow(multiMaxAggregator);
    222237
    223         IAggregator multiMinAggregator = new MinAggregator();
     238        MinAggregator multiMinAggregator = new MinAggregator();
    224239        multiMinAggregator.Label = "MultiMinAggregator";
    225240        multiMinAggregator.Color = Color.DarkRed;
     
    231246        model.AddDataRow(multiMinAggregator);
    232247
    233         IAggregator multiLineAvgAggregator = new AvgLineAggregator();
     248        AvgLineAggregator multiLineAvgAggregator = new AvgLineAggregator();
    234249        multiLineAvgAggregator.Label = "MultiLineAvgAggregator";
    235250        multiLineAvgAggregator.Color = Color.Red;
  • trunk/sources/HeuristicLab.Visualization/AvgAggregator.cs

    r1343 r1350  
    11using System;
    22using System.Collections.Generic;
    3 using System.Drawing;
    43
    54namespace HeuristicLab.Visualization {
    6   public class AvgAggregator : IAggregator {
    7 
    8 
     5  public class AvgAggregator : DataRowBase {
    96    #region IAggregator Members
    107
     
    1714
    1815    public void RemoveWatch(IDataRow dataRow) {
    19 
    2016      dataRowWatches.Remove(dataRow);
    2117      dataRow.DataRowChanged -= dataRow_DataRowChanged;
     
    2420    }
    2521
    26 
    2722    #endregion
    2823
    29     List<IDataRow> dataRowWatches = new List<IDataRow>();
    30     double curAvgValue;
     24    private List<IDataRow> dataRowWatches = new List<IDataRow>();
     25    private double curAvgValue;
    3126
    32     void dataRow_ValueChanged(IDataRow row, double value, int index, Action action) {
     27    private void dataRow_ValueChanged(IDataRow row, double value, int index, Action action) {
    3328      refreshValue(value);
    3429    }
    3530
    36     void dataRow_ValuesChanged(IDataRow row, double[] values, int index, Action action) {
     31    private void dataRow_ValuesChanged(IDataRow row, double[] values, int index, Action action) {
    3732      for (int i = 0; i < values.Length; i++) {
    3833        refreshValue(values[i]);
     
    4035    }
    4136
    42     void dataRow_DataRowChanged(IDataRow row) {
     37    private void dataRow_DataRowChanged(IDataRow row) {
    4338      refreshValue(double.MinValue);
    4439    }
     
    5045      double tmpSum = 0;
    5146      int count = 0;
    52       foreach (var rows in dataRowWatches) {
     47      foreach (IDataRow rows in dataRowWatches) {
    5348        for (int i = 0; i < rows.Count; i++) {
    5449          tmpSum += rows[i];
     
    6358    #region IDataRow Members
    6459
    65     private string label = "";
    66     private Color color = Color.Black;
    67     private int thickness = 2;
    68     private DrawingStyle style = DrawingStyle.Solid;
    69     private DataRowType lineType = DataRowType.Normal;
    70 
    71 
    72     public string Label {
    73       get { return label; }
    74       set {
    75         label = value;
    76         OnDataRowChanged(this);
    77       }
    78     }
    79 
    80     public Color Color {
    81       get { return color; }
    82       set {
    83         color = value;
    84         OnDataRowChanged(this);
    85       }
    86     }
    87 
    88     public int Thickness {
    89       get { return thickness; }
    90       set {
    91         thickness = value;
    92         OnDataRowChanged(this);
    93       }
    94     }
    95 
    96     public DrawingStyle Style {
    97       get { return style; }
    98       set {
    99         style = value;
    100         OnDataRowChanged(this);
    101       }
    102     }
    103 
    104     public DataRowType LineType {
    105       get { return lineType; }
    106       set {
    107         lineType = value;
    108         OnDataRowChanged(this);
    109       }
    110     }
    111 
    112     private bool showYAxis = false;
    113 
    114     public bool ShowYAxis {
    115       get { return showYAxis; }
    116       set {
    117         showYAxis = value;
    118         OnDataRowChanged(this);
    119       }
    120     }
    121 
    122     public LabelProvider.ILabelProvider YAxisLabelProvider {
    123       get {
    124         throw new NotImplementedException();
    125       }
    126       set {
    127         throw new NotImplementedException();
    128       }
    129     }
    130 
    131     public void AddValue(double value) {
     60    public override void AddValue(double value) {
    13261      throw new NotSupportedException();
    13362    }
    13463
    135     public void AddValue(double value, int index) {
     64    public override void AddValue(double value, int index) {
    13665      throw new NotSupportedException();
    13766    }
    13867
    139     public void AddValues(double[] values) {
     68    public override void AddValues(double[] values) {
    14069      throw new NotSupportedException();
    14170    }
    14271
    143     public void AddValues(double[] values, int index) {
     72    public override void AddValues(double[] values, int index) {
    14473      throw new NotSupportedException();
    14574    }
    14675
    147     public void ModifyValue(double value, int index) {
     76    public override void ModifyValue(double value, int index) {
    14877      throw new NotSupportedException();
    14978    }
    15079
    151     public void ModifyValues(double[] values, int index) {
     80    public override void ModifyValues(double[] values, int index) {
    15281      throw new NotSupportedException();
    15382    }
    15483
    155     public void RemoveValue(int index) {
     84    public override void RemoveValue(int index) {
    15685      throw new NotSupportedException();
    15786    }
    15887
    159     public void RemoveValues(int index, int count) {
     88    public override void RemoveValues(int index, int count) {
    16089      throw new NotSupportedException();
    16190    }
    16291
    163     public int Count {
     92    public override int Count {
    16493      get { return 1; }
    16594    }
    16695
    167     public double this[int index] {
    168       get {
    169         return curAvgValue;
    170       }
    171       set {
    172         throw new NotSupportedException();
    173       }
     96    public override double this[int index] {
     97      get { return curAvgValue; }
     98      set { throw new NotSupportedException(); }
    17499    }
    175100
    176     public double MinValue {
    177       get { throw new System.NotImplementedException(); }
     101    public override double MinValue {
     102      get { return curAvgValue; }
    178103    }
    179104
    180     public double MaxValue {
    181       get { throw new System.NotImplementedException(); }
    182     }
    183 
    184     public event ValuesChangedHandler ValuesChanged;
    185 
    186     protected void OnValuesChanged(double[] values, int index, Action action) {
    187       if (ValuesChanged != null) {
    188         ValuesChanged(this, values, index, action);
    189       }
    190     }
    191 
    192     public event ValueChangedHandler ValueChanged;
    193 
    194     protected void OnValueChanged(double value, int index, Action action) {
    195       if (ValueChanged != null) {
    196         ValueChanged(this, value, index, action);
    197       }
    198     }
    199 
    200     public event DataRowChangedHandler DataRowChanged;
    201 
    202     protected void OnDataRowChanged(IDataRow row) {
    203       if (DataRowChanged != null) {
    204         DataRowChanged(this);
    205       }
     105    public override double MaxValue {
     106      get { return curAvgValue; }
    206107    }
    207108
  • trunk/sources/HeuristicLab.Visualization/AvgLineAggregator.cs

    r1343 r1350  
    11using System;
    22using System.Collections.Generic;
    3 using System.Drawing;
    43
    54namespace HeuristicLab.Visualization {
    6   public class AvgLineAggregator : IAggregator {
     5  public class AvgLineAggregator : DataRowBase {
    76
    87    private readonly List<double> dataRow = new List<double>();
     
    7776    #region IDataRow Members
    7877
    79     private string label = "";
    80     private Color color = Color.Black;
    81     private int thickness = 2;
    82     private DrawingStyle style = DrawingStyle.Solid;
    83     private DataRowType lineType = DataRowType.Normal;
    84 
    85 
    86     public string Label {
    87       get { return label; }
    88       set {
    89         label = value;
    90         OnDataRowChanged(this);
    91       }
    92     }
    93 
    94     public Color Color {
    95       get { return color; }
    96       set {
    97         color = value;
    98         OnDataRowChanged(this);
    99       }
    100     }
    101 
    102     public int Thickness {
    103       get { return thickness; }
    104       set {
    105         thickness = value;
    106         OnDataRowChanged(this);
    107       }
    108     }
    109 
    110     public DrawingStyle Style {
    111       get { return style; }
    112       set {
    113         style = value;
    114         OnDataRowChanged(this);
    115       }
    116     }
    117 
    118     public DataRowType LineType {
    119       get { return lineType; }
    120       set {
    121         lineType = value;
    122         OnDataRowChanged(this);
    123       }
    124     }
    125 
    126 
    127     private bool showYAxis = false;
    128 
    129     public bool ShowYAxis {
    130       get { return showYAxis; }
    131       set {
    132         showYAxis = value;
    133         OnDataRowChanged(this);
    134       }
    135     }
    136 
    137     public LabelProvider.ILabelProvider YAxisLabelProvider {
    138       get {
    139         throw new NotImplementedException();
    140       }
    141       set {
    142         throw new NotImplementedException();
    143       }
    144     }
    145 
    146     public void AddValue(double value) {
     78    public override void AddValue(double value) {
    14779      dataRow.Add(value);
    14880      OnValueChanged(value, dataRow.Count - 1, Action.Added);
    14981    }
    15082
    151     public void AddValue(double value, int index) {
    152       throw new System.NotImplementedException();
     83    public override void AddValue(double value, int index) {
     84      throw new NotImplementedException();
    15385    }
    15486
    155     public void AddValues(double[] values) {
     87    public override void AddValues(double[] values) {
    15688      throw new NotSupportedException();
    15789    }
    15890
    159     public void AddValues(double[] values, int index) {
     91    public override void AddValues(double[] values, int index) {
    16092      throw new NotSupportedException();
    16193    }
    16294
    163     public void ModifyValue(double value, int index) {
     95    public override void ModifyValue(double value, int index) {
    16496      throw new NotSupportedException();
    16597    }
    16698
    167     public void ModifyValues(double[] values, int index) {
     99    public override void ModifyValues(double[] values, int index) {
    168100      throw new NotSupportedException();
    169101    }
    170102
    171     public void RemoveValue(int index) {
     103    public override void RemoveValue(int index) {
    172104      throw new NotSupportedException();
    173105    }
    174106
    175     public void RemoveValues(int index, int count) {
     107    public override void RemoveValues(int index, int count) {
    176108      throw new NotSupportedException();
    177109    }
    178110
    179     public int Count {
     111    public override int Count {
    180112      get { return dataRowWatches.Count; }
    181113    }
    182114
    183     public double this[int index] {
     115    public override double this[int index] {
    184116      get { return dataRow[index]; }
    185117      set {
     
    189121    }
    190122
    191     public double MinValue {
    192       get { throw new System.NotImplementedException(); }
     123    // TODO calculate min value
     124    public override double MinValue {
     125      get { return 0; }
    193126    }
    194127
    195     public double MaxValue {
    196       get { throw new System.NotImplementedException(); }
    197     }
    198 
    199     public event ValuesChangedHandler ValuesChanged;
    200 
    201     protected void OnValuesChanged(double[] values, int index, Action action) {
    202       if (ValuesChanged != null) {
    203         ValuesChanged(this, values, index, action);
    204       }
    205     }
    206 
    207     public event ValueChangedHandler ValueChanged;
    208 
    209     protected void OnValueChanged(double value, int index, Action action) {
    210       if (ValueChanged != null) {
    211         ValueChanged(this, value, index, action);
    212       }
    213     }
    214 
    215     public event DataRowChangedHandler DataRowChanged;
    216 
    217     protected void OnDataRowChanged(IDataRow row) {
    218       if (DataRowChanged != null) {
    219         DataRowChanged(this);
    220       }
     128    // TODO calculate max value
     129    public override double MaxValue {
     130      get { return 0; }
    221131    }
    222132
  • trunk/sources/HeuristicLab.Visualization/ChartDataRowsModel.cs

    r1341 r1350  
    2828    }
    2929
     30    public List<YAxisDescriptor> YAxes {
     31      get {
     32        Dictionary<YAxisDescriptor, object> yaxes = new Dictionary<YAxisDescriptor, object>();
     33
     34        foreach (IDataRow row in rows) {
     35          yaxes[row.YAxis] = null;
     36        }
     37
     38        return new List<YAxisDescriptor>(yaxes.Keys);
     39      }
     40    }
     41
    3042
    3143    private readonly List<IDataRow> rows = new List<IDataRow>();
     
    111123    //}
    112124
     125    private readonly YAxisDescriptor defaultYAxisDescriptor = new YAxisDescriptor();
     126
    113127    public void AddDataRow(IDataRow row) {
     128      if (row.YAxis == null) {
     129        row.YAxis = defaultYAxisDescriptor;
     130      }
    114131      rows.Add(row);
    115132      OnDataRowAdded(row);
  • trunk/sources/HeuristicLab.Visualization/DataRow.cs

    r1343 r1350  
    1515  public delegate void ValueChangedHandler(IDataRow row, double value, int index, Action action);
    1616
    17   public class DataRow : IDataRow {
    18     private string label = "";
    19     private Color color = Color.Black;
    20     private int thickness = 2;
    21     private DrawingStyle style = DrawingStyle.Solid;
    22     private DataRowType lineType = DataRowType.Normal;
     17  public class DataRow : DataRowBase {
    2318    private readonly List<double> dataRow = new List<double>();
    24 
    25     private ILabelProvider labelProvider = new ContinuousLabelProvider("0.##");
    2619
    2720    // TODO implement calculation of min and max values
    2821    private double minValue = double.MaxValue;
    2922    private double maxValue = double.MinValue;
    30 
    31     public DataRowType LineType{
    32       get { return lineType; }
    33       set {
    34         lineType = value;
    35         OnDataRowChanged(this);
    36       }
    37     }
    38 
    39     public ILabelProvider YAxisLabelProvider {
    40       get { return labelProvider; }
    41       set {
    42         this.labelProvider = value;
    43         OnDataRowChanged(this);
    44       }
    45     }
    4623
    4724    public DataRow() {
     
    6037    }
    6138
    62     public event DataRowChangedHandler DataRowChanged;
    63 
    64     protected void OnDataRowChanged(IDataRow row) {
    65       if (DataRowChanged != null) {
    66         DataRowChanged(this);
    67       }
    68     }
    69 
    70     public event ValuesChangedHandler ValuesChanged;
    71 
    72     protected void OnValuesChanged(double[] values, int index, Action action) {
    73       if (ValuesChanged != null) {
    74         ValuesChanged(this, values, index, action);
    75       }
    76     }
    77 
    78     public event ValueChangedHandler ValueChanged;
    79 
    80     protected void OnValueChanged(double value, int index, Action action) {
    81       if (ValueChanged != null) {
    82         ValueChanged(this, value, index, action);
    83       }
    84     }
    85  
    86     public string Label {
    87       get { return label; }
    88       set {
    89         label = value;
    90         OnDataRowChanged(this);
    91       }
    92     }
    93    
    94 
    95     public Color Color {
    96       get { return color; }
    97       set {
    98         color = value;
    99         OnDataRowChanged(this);
    100       }
    101     }
    102 
    103     public int Thickness {
    104       get { return thickness; }
    105       set {
    106         thickness = value;
    107         OnDataRowChanged(this);
    108       }
    109     }
    110 
    111     public DrawingStyle Style {
    112       get { return style; }
    113       set {
    114         style = value;
    115         OnDataRowChanged(this);
    116       }
    117     }
    118 
    119     private bool showYAxis = true;
    120 
    121     public virtual bool ShowYAxis {
    122       get { return showYAxis; }
    123       set {
    124         showYAxis = value;
    125         OnDataRowChanged(this);
    126       }
    127     }
    128 
    129     public void AddValue(double value) {
     39    public override void AddValue(double value) {
    13040      UpdateMinMaxValue(value);
    13141
     
    13444    }
    13545
    136     public void AddValue(double value, int index) {
     46    public override void AddValue(double value, int index) {
    13747      //check if index is valid
    13848      if (index >= 0 && index < dataRow.Count) {
     
    14454    }
    14555
    146     public void AddValues(double[] values) {
     56    public override void AddValues(double[] values) {
    14757      int startInd = dataRow.Count;
    14858
     
    15363    }
    15464
    155     public void AddValues(double[] values, int index) {
     65    public override void AddValues(double[] values, int index) {
    15666      int j = index;
    15767
     
    16878    }
    16979
    170     public void ModifyValue(double value, int index) {
     80    public override void ModifyValue(double value, int index) {
    17181      //check if index is valid
    17282      if (index >= 0 && index < dataRow.Count) {
     
    17888    }
    17989
    180     public void ModifyValues(double[] values, int index) {
     90    public override void ModifyValues(double[] values, int index) {
    18191      int startInd = index;
    18292      int modInd = index;
     
    194104    }
    195105
    196     public void RemoveValue(int index) {
     106    public override void RemoveValue(int index) {
    197107      double remVal = dataRow[index];
    198108      //check if index is valid
     
    205115    }
    206116
    207     public void RemoveValues(int index, int count) {
     117    public override void RemoveValues(int index, int count) {
    208118      double[] remValues = new double[count]; //removed values
    209119      int j = 0;
     
    227137    }
    228138
    229     public int Count {
     139    public override int Count {
    230140      get { return dataRow.Count; }
    231141    }
    232142
    233     public double this[int index] {
     143    public override double this[int index] {
    234144      get { return dataRow[index]; }
    235145      set {
     
    239149    }
    240150
    241     public double MinValue {
     151    public override double MinValue {
    242152      get { return minValue; }
    243153    }
    244154
    245     public double MaxValue {
     155    public override double MaxValue {
    246156      get { return maxValue; }
    247157    }
  • trunk/sources/HeuristicLab.Visualization/HeuristicLab.Visualization.csproj

    r1341 r1350  
    44    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    55    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    6     <ProductVersion>9.0.30729</ProductVersion>
     6    <ProductVersion>9.0.21022</ProductVersion>
    77    <SchemaVersion>2.0</SchemaVersion>
    88    <ProjectGuid>{E392A1E2-DC95-4E33-B82E-8ED690EDA1AB}</ProjectGuid>
     
    8484    <Compile Include="CompositeShape.cs" />
    8585    <Compile Include="ChartDataRowsModelDataCollector.cs" />
    86     <Compile Include="IAggregator.cs" />
     86    <Compile Include="DataRowBase.cs" />
    8787    <Compile Include="LabelProvider\ContinuousLabelProvider.cs" />
    8888    <Compile Include="LabelProvider\DiscreteLabelProvider.cs" />
     
    130130    <Compile Include="XAxis.cs" />
    131131    <Compile Include="YAxis.cs" />
     132    <Compile Include="YAxisDescriptor.cs" />
    132133    <Compile Include="ZoomListener.cs" />
    133134  </ItemGroup>
  • trunk/sources/HeuristicLab.Visualization/IChartDataRowsModel.cs

    r1341 r1350  
    77  public interface IChartDataRowsModel : IItem {
    88    string Title { get; set; }
    9     //string XAxisLabel { get; set; }
    10     //List<string> XLabels { get; }
    119    List<IDataRow> Rows { get; }
    1210    ILabelProvider XAxisLabelProvider { get; set; }
    1311
     12    List<YAxisDescriptor> YAxes { get; }
     13
    1414    void AddDataRow(IDataRow row);
    1515    void RemoveDataRow(IDataRow row);
    16 
    17     //void AddLabel(string label);
    18     //void AddLabel(string label, int index);
    19     //void AddLabels(string[] labels);
    20     //void AddLabels(string[] labels, int index);
    21     //void ModifyLabel(string label, int index);
    22     //void ModifyLabels(string[] labels, int index);
    23     //void RemoveLabel(int index);
    24     //void RemoveLabels(int index, int count);
    2516
    2617    int MaxDataRowValues { get; }
  • trunk/sources/HeuristicLab.Visualization/IDataRow.cs

    r1343 r1350  
    11using System.Drawing;
    2 using HeuristicLab.Visualization.LabelProvider;
    32
    43namespace HeuristicLab.Visualization {
    5 
    64  public enum DataRowType {
    75    Normal, SingleValue
     
    1513    DataRowType LineType { get; set; }
    1614 
    17     bool ShowYAxis { get; set; }
    18     ILabelProvider YAxisLabelProvider { get; set; }
    19 
    20     /// <summary>
    21     /// Raised when data row data changed. Should cause redraw in the view.
    22     /// </summary>
     15    YAxisDescriptor YAxis { get; set; }
    2316
    2417    void AddValue(double value);
  • trunk/sources/HeuristicLab.Visualization/LineChart.cs

    r1346 r1350  
    2929    private const int XAxisHeight = 20;
    3030
    31     private bool zoomToFullView;
    32 
    33 
    3431    /// <summary>
    3532    /// This constructor shouldn't be called. Only required for the designer.
     
    8683      canvas.ClearShapes();
    8784
    88       foreach (RowEntry rowEntry in rowEntries) {
    89         canvas.AddShape(rowEntry.Grid);
     85      foreach (YAxisDescriptor yAxisDescriptor in model.YAxes) {
     86        YAxisInfo info = GetYAxisInfo(yAxisDescriptor);
     87        canvas.AddShape(info.Grid);
    9088      }
    9189
     
    9896      int yAxesWidth = 0;
    9997
    100       foreach (RowEntry rowEntry in rowEntries) {
    101         if (rowEntry.DataRow.ShowYAxis) {
    102           canvas.AddShape(rowEntry.YAxis);
     98      foreach (YAxisDescriptor yAxisDescriptor in model.YAxes) {
     99        YAxisInfo info = GetYAxisInfo(yAxisDescriptor);
     100        if (yAxisDescriptor.ShowYAxis) {
     101          canvas.AddShape(info.YAxis);
    103102          yAxesWidth += YAxisWidth;
    104103        }
     
    120119      foreach (RowEntry rowEntry in rowEntries) {
    121120        rowEntry.LinesShape.BoundingBox = linesAreaBoundingBox;
    122         rowEntry.Grid.BoundingBox = linesAreaBoundingBox;
     121      }
     122
     123      foreach (YAxisDescriptor yAxisDescriptor in model.YAxes) {
     124        YAxisInfo info = GetYAxisInfo(yAxisDescriptor);
     125        info.Grid.BoundingBox = linesAreaBoundingBox;
    123126      }
    124127
    125128      int yAxisLeft = 0;
    126       foreach (RowEntry rowEntry in rowEntries) {
    127         if (rowEntry.DataRow.ShowYAxis) {
    128           rowEntry.YAxis.BoundingBox = new RectangleD(yAxisLeft,
    129                                                       linesAreaBoundingBox.Y1,
    130                                                       yAxisLeft + YAxisWidth,
    131                                                       linesAreaBoundingBox.Y2);
     129      foreach (YAxisDescriptor yAxisDescriptor in model.YAxes) {
     130        YAxisInfo info = GetYAxisInfo(yAxisDescriptor);
     131        if (yAxisDescriptor.ShowYAxis) {
     132          info.YAxis.BoundingBox = new RectangleD(yAxisLeft,
     133                                                 linesAreaBoundingBox.Y1,
     134                                                 yAxisLeft + YAxisWidth,
     135                                                 linesAreaBoundingBox.Y2);
    132136          yAxisLeft += YAxisWidth;
    133137        }
     
    143147
    144148      SetLegendPosition();
     149    }
     150
     151    private readonly Dictionary<YAxisDescriptor, YAxisInfo> yAxisInfos = new Dictionary<YAxisDescriptor, YAxisInfo>();
     152
     153    private YAxisInfo GetYAxisInfo(YAxisDescriptor yAxisDescriptor) {
     154      YAxisInfo info;
     155
     156      if (!yAxisInfos.TryGetValue(yAxisDescriptor, out info)) {
     157        info = new YAxisInfo();
     158        yAxisInfos[yAxisDescriptor] = info;
     159      }
     160
     161      return info;
     162    }
     163
     164    private void UpdateYAxisInfo(YAxisDescriptor yAxisDescriptor) {
     165//      if (yAxisInfos.ContainsKey(yAxisDescriptor)) {
     166//        yAxisInfos.Remove(yAxisDescriptor);
     167//      }
    145168    }
    146169
     
    206229    private void optionsToolStripMenuItem_Click(object sender, EventArgs e) {
    207230      OptionsDialog optionsdlg = new OptionsDialog(model);
    208       //var optionsdlg = new OptionsDialog(model, this);
    209231      optionsdlg.ShowDialog(this);
    210232      Invalidate();
     
    212234
    213235    public void OnDataRowChanged(IDataRow row) {
     236      UpdateYAxisInfo(row.YAxis);
     237
    214238      RowEntry rowEntry = rowToRowEntry[row];
    215239
     
    273297
    274298      foreach (RowEntry rowEntry in rowEntries) {
    275         IDataRow row = rowEntry.DataRow;
     299        YAxisDescriptor yAxisDescriptor = rowEntry.DataRow.YAxis;
    276300
    277301        SetClipY(rowEntry,
    278                  row.MinValue - ((row.MaxValue - row.MinValue)*0.05),
    279                  row.MaxValue + ((row.MaxValue - row.MinValue)*0.05));
    280       }
    281 
    282       zoomToFullView = true;
     302                 yAxisDescriptor.MinValue - ((yAxisDescriptor.MaxValue - yAxisDescriptor.MinValue)*0.05),
     303                 yAxisDescriptor.MaxValue + ((yAxisDescriptor.MaxValue - yAxisDescriptor.MinValue)*0.05));
     304      }
    283305
    284306      canvasUI.Invalidate();
     
    296318                                                          x2,
    297319                                                          rowEntry.LinesShape.ClippingArea.Y2);
    298         rowEntry.Grid.ClippingArea = new RectangleD(x1,
    299                                                     rowEntry.Grid.ClippingArea.Y1,
    300                                                     x2,
    301                                                     rowEntry.Grid.ClippingArea.Y2);
    302         rowEntry.YAxis.ClippingArea = new RectangleD(0,
    303                                                      rowEntry.YAxis.ClippingArea.Y1,
    304                                                      YAxisWidth,
    305                                                      rowEntry.YAxis.ClippingArea.Y2);
    306       }
    307     }
    308 
    309     private static void SetClipY(RowEntry rowEntry, double y1, double y2) {
     320      }
     321
     322      foreach (YAxisDescriptor yAxisDescriptor in model.YAxes) {
     323        YAxisInfo info = GetYAxisInfo(yAxisDescriptor);
     324        info.Grid.ClippingArea = new RectangleD(x1,
     325                                                info.Grid.ClippingArea.Y1,
     326                                                x2,
     327                                                info.Grid.ClippingArea.Y2);
     328        info.YAxis.ClippingArea = new RectangleD(0,
     329                                                 info.YAxis.ClippingArea.Y1,
     330                                                 YAxisWidth,
     331                                                 info.YAxis.ClippingArea.Y2);
     332      }
     333    }
     334
     335    private void SetClipY(RowEntry rowEntry, double y1, double y2) {
    310336      rowEntry.LinesShape.ClippingArea = new RectangleD(rowEntry.LinesShape.ClippingArea.X1,
    311337                                                        y1,
    312338                                                        rowEntry.LinesShape.ClippingArea.X2,
    313339                                                        y2);
    314       rowEntry.Grid.ClippingArea = new RectangleD(rowEntry.Grid.ClippingArea.X1,
    315                                                   y1,
    316                                                   rowEntry.Grid.ClippingArea.X2,
    317                                                   y2);
    318       rowEntry.YAxis.ClippingArea = new RectangleD(rowEntry.YAxis.ClippingArea.X1,
    319                                                    y1,
    320                                                    rowEntry.YAxis.ClippingArea.X2,
    321                                                    y2);
     340
     341      YAxisInfo info = GetYAxisInfo(rowEntry.DataRow.YAxis);
     342
     343      info.Grid.ClippingArea = new RectangleD(info.Grid.ClippingArea.X1,
     344                                              y1,
     345                                              info.Grid.ClippingArea.X2,
     346                                              y2);
     347      info.YAxis.ClippingArea = new RectangleD(info.YAxis.ClippingArea.X1,
     348                                               y1,
     349                                               info.YAxis.ClippingArea.X2,
     350                                               y2);
    322351    }
    323352
     
    418447
    419448    private void Pan(Point startPoint, Point endPoint) {
    420       zoomToFullView = false;
    421 
    422449      foreach (RowEntry rowEntry in rowEntries) {
    423450        RectangleD clippingArea = CalcPanClippingArea(startPoint, endPoint, rowEntry.LinesShape);
     
    431458
    432459    private void PanEnd(Point startPoint, Point endPoint) {
    433       zoomToFullView = false;
    434 
    435460      foreach (RowEntry rowEntry in rowEntries) {
    436461        RectangleD clippingArea = CalcPanClippingArea(startPoint, endPoint, rowEntry.LinesShape);
     
    552577      private readonly IDataRow dataRow;
    553578
     579      private readonly LinesShape linesShape = new LinesShape();
     580
     581      public RowEntry(IDataRow dataRow) {
     582        this.dataRow = dataRow;
     583      }
     584
     585      public IDataRow DataRow {
     586        get { return dataRow; }
     587      }
     588
     589      public LinesShape LinesShape {
     590        get { return linesShape; }
     591      }
     592    }
     593
     594    private class YAxisInfo {
    554595      private readonly Grid grid = new Grid();
    555596      private readonly YAxis yAxis = new YAxis();
    556       private readonly LinesShape linesShape = new LinesShape();
    557 
    558       public RowEntry(IDataRow dataRow) {
    559         this.dataRow = dataRow;
    560       }
    561 
    562       public IDataRow DataRow {
    563         get { return dataRow; }
    564       }
    565597
    566598      public Grid Grid {
     
    571603        get { return yAxis; }
    572604      }
    573 
    574       public LinesShape LinesShape {
    575         get { return linesShape; }
    576       }
    577605    }
    578606  }
  • trunk/sources/HeuristicLab.Visualization/MaxAggregator.cs

    r1343 r1350  
    44
    55namespace HeuristicLab.Visualization {
    6   public class MaxAggregator : IAggregator {
    7    
    8    
     6  public class MaxAggregator : DataRowBase {
    97    #region IAggregator Members
    108
     
    5149      } else {
    5250        curMaxValue = double.MinValue;
    53         foreach (var rows in dataRowWatches) {
     51        foreach (IDataRow rows in dataRowWatches) {
    5452          for (int i = 0; i < rows.Count; i++) {
    5553            if (rows[i] > curMaxValue) {
     
    6563
    6664    #region IDataRow Members
    67 
    68     private string label = "";
    69     private Color color = Color.Black;
    70     private int thickness = 2;
    71     private DrawingStyle style = DrawingStyle.Solid;
    72     private DataRowType lineType = DataRowType.Normal;
    73 
    74 
    75     public string Label {
    76       get { return label; }
    77       set {
    78         label = value;
    79         OnDataRowChanged(this);
    80       }
    81     }
    82 
    83     public Color Color {
    84       get { return color; }
    85       set {
    86         color = value;
    87         OnDataRowChanged(this);
    88       }
    89     }
    90 
    91     public int Thickness {
    92       get { return thickness; }
    93       set {
    94         thickness = value;
    95         OnDataRowChanged(this);
    96       }
    97     }
    98 
    99     public DrawingStyle Style {
    100       get { return style; }
    101       set {
    102         style = value;
    103         OnDataRowChanged(this);
    104       }
    105     }
    106 
    107     public DataRowType LineType {
    108       get { return lineType; }
    109       set {
    110         lineType = value;
    111         OnDataRowChanged(this);
    112       }
    113     }
    114 
    115     private bool showYAxis = false;
    116 
    117     public bool ShowYAxis {
    118       get { return showYAxis; }
    119       set {
    120         showYAxis = value;
    121         OnDataRowChanged(this);
    122       }
    123     }
    124 
    125     public LabelProvider.ILabelProvider YAxisLabelProvider {
    126       get {
    127         throw new NotImplementedException();
    128       }
    129       set {
    130         throw new NotImplementedException();
    131       }
    132     }
    133 
    134     public void AddValue(double value) {
     65    public override void AddValue(double value) {
    13566      OnValueChanged(2, 0, Action.Added);
    13667    }
    13768
    138     public void AddValue(double value, int index) {
     69    public override void AddValue(double value, int index) {
    13970      throw new NotSupportedException();
    14071    }
    14172
    142     public void AddValues(double[] values) {
     73    public override void AddValues(double[] values) {
    14374      throw new NotSupportedException();
    14475    }
    14576
    146     public void AddValues(double[] values, int index) {
     77    public override void AddValues(double[] values, int index) {
    14778      throw new NotSupportedException();
    14879    }
    14980
    150     public void ModifyValue(double value, int index) {
     81    public override void ModifyValue(double value, int index) {
    15182      throw new NotSupportedException();
    15283    }
    15384
    154     public void ModifyValues(double[] values, int index) {
     85    public override void ModifyValues(double[] values, int index) {
    15586      throw new NotSupportedException();
    15687    }
    15788
    158     public void RemoveValue(int index) {
     89    public override void RemoveValue(int index) {
    15990      throw new NotSupportedException();
    16091    }
    16192
    162     public void RemoveValues(int index, int count) {
     93    public override void RemoveValues(int index, int count) {
    16394      throw new NotSupportedException();
    16495    }
    16596
    166     public int Count {
     97    public override int Count {
    16798      get { return 1; }
    16899    }
    169100
    170     public double this[int index] {
     101    public override double this[int index] {
    171102      get {
    172103        return curMaxValue;
     
    177108    }
    178109
    179     public double MinValue {
    180       get { throw new System.NotImplementedException(); }
     110    public override double MinValue {
     111      get { return curMaxValue; }
    181112    }
    182113
    183     public double MaxValue {
    184       get { throw new System.NotImplementedException(); }
    185     }
    186 
    187     public event ValuesChangedHandler ValuesChanged;
    188 
    189     protected void OnValuesChanged(double[] values, int index, Action action) {
    190       if (ValuesChanged != null) {
    191         ValuesChanged(this, values, index, action);
    192       }
    193     }
    194 
    195     public event ValueChangedHandler ValueChanged;
    196 
    197     protected void OnValueChanged(double value, int index, Action action) {
    198       if (ValueChanged != null) {
    199         ValueChanged(this, value, index, action);
    200       }
    201     }
    202 
    203     public event DataRowChangedHandler DataRowChanged;
    204 
    205     protected void OnDataRowChanged(IDataRow row) {
    206       if (DataRowChanged != null) {
    207         DataRowChanged(this);
    208       }
     114    public override double MaxValue {
     115      get { return curMaxValue; }
    209116    }
    210117
  • trunk/sources/HeuristicLab.Visualization/MinAggregator.cs

    r1343 r1350  
    11using System;
    22using System.Collections.Generic;
    3 using System.Drawing;
    4 using HeuristicLab.Visualization.LabelProvider;
    53
    64namespace HeuristicLab.Visualization {
    7   public class MinAggregator : IAggregator {
     5  public class MinAggregator : DataRowBase {
    86    #region IAggregator Members
    97
     
    5048      } else {
    5149        curMinValue = double.MaxValue;
    52         foreach (var rows in dataRowWatches) {
     50        foreach (IDataRow rows in dataRowWatches) {
    5351          for (int i = 0; i < rows.Count; i++) {
    5452            if (rows[i] < curMinValue) {
     
    6563    #region IDataRow Members
    6664
    67     private string label = "";
    68     private Color color = Color.Black;
    69     private int thickness = 2;
    70     private DrawingStyle style = DrawingStyle.Solid;
    71     private DataRowType lineType = DataRowType.Normal;
    72 
    73 
    74     public string Label {
    75       get { return label; }
    76       set {
    77         label = value;
    78         OnDataRowChanged(this);
    79       }
    80     }
    81 
    82     public Color Color {
    83       get { return color; }
    84       set {
    85         color = value;
    86         OnDataRowChanged(this);
    87       }
    88     }
    89 
    90     public int Thickness {
    91       get { return thickness; }
    92       set {
    93         thickness = value;
    94         OnDataRowChanged(this);
    95       }
    96     }
    97 
    98     public DrawingStyle Style {
    99       get { return style; }
    100       set {
    101         style = value;
    102         OnDataRowChanged(this);
    103       }
    104     }
    105 
    106     public DataRowType LineType {
    107       get { return lineType; }
    108       set {
    109         lineType = value;
    110         OnDataRowChanged(this);
    111       }
    112     }
    113 
    114 
    115     private bool showYAxis = false;
    116 
    117     public bool ShowYAxis {
    118       get { return showYAxis; }
    119       set {
    120         showYAxis = value;
    121         OnDataRowChanged(this);
    122       }
    123     }
    124 
    125     private ILabelProvider labelProvider = new ContinuousLabelProvider("0.##");
    126     public ILabelProvider YAxisLabelProvider {
    127       get { return labelProvider; }
    128       set {
    129         this.labelProvider = value;
    130         OnDataRowChanged(this);
    131       }
    132     }
    133 
    134     public void AddValue(double value) {
     65    public override void AddValue(double value) {
    13566      OnValueChanged(2, 0, Action.Added);
    13667    }
    13768
    138     public void AddValue(double value, int index) {
     69    public override void AddValue(double value, int index) {
    13970      throw new NotSupportedException();
    14071    }
    14172
    142     public void AddValues(double[] values) {
     73    public override void AddValues(double[] values) {
    14374      throw new NotSupportedException();
    14475    }
    14576
    146     public void AddValues(double[] values, int index) {
     77    public override void AddValues(double[] values, int index) {
    14778      throw new NotSupportedException();
    14879    }
    14980
    150     public void ModifyValue(double value, int index) {
     81    public override void ModifyValue(double value, int index) {
    15182      throw new NotSupportedException();
    15283    }
    15384
    154     public void ModifyValues(double[] values, int index) {
     85    public override void ModifyValues(double[] values, int index) {
    15586      throw new NotSupportedException();
    15687    }
    15788
    158     public void RemoveValue(int index) {
     89    public override void RemoveValue(int index) {
    15990      throw new NotSupportedException();
    16091    }
    16192
    162     public void RemoveValues(int index, int count) {
     93    public override void RemoveValues(int index, int count) {
    16394      throw new NotSupportedException();
    16495    }
    16596
    166     public int Count {
     97    public override int Count {
    16798      get { return 1; }
    16899    }
    169100
    170     public double this[int index] {
     101    public override double this[int index] {
    171102      get {
    172103        return curMinValue;
     
    177108    }
    178109
    179     public double MinValue {
    180       get { throw new System.NotImplementedException(); }
     110    public override double MinValue {
     111      get { return curMinValue; }
    181112    }
    182113
    183     public double MaxValue {
    184       get { throw new System.NotImplementedException(); }
    185     }
    186 
    187     public event ValuesChangedHandler ValuesChanged;
    188 
    189     protected void OnValuesChanged(double[] values, int index, Action action) {
    190       if (ValuesChanged != null) {
    191         ValuesChanged(this, values, index, action);
    192       }
    193     }
    194 
    195     public event ValueChangedHandler ValueChanged;
    196 
    197     protected void OnValueChanged(double value, int index, Action action) {
    198       if (ValueChanged != null) {
    199         ValueChanged(this, value, index, action);
    200       }
    201     }
    202 
    203     public event DataRowChangedHandler DataRowChanged;
    204 
    205     protected void OnDataRowChanged(IDataRow row) {
    206       if (DataRowChanged != null) {
    207         DataRowChanged(this);
    208       }
     114    public override double MaxValue {
     115      get { return curMinValue; }
    209116    }
    210117
  • trunk/sources/HeuristicLab.Visualization/Options/OptionsDialog.cs

    r1345 r1350  
    5252
    5353    private void InitTabPageYAxes() {
    54       for (int i = 0; i < model.Rows.Count; i++) {
    55         IDataRow row = model.Rows[i];
     54      for (int i = 0; i < model.YAxes.Count; i++) {
     55        YAxisDescriptor yAxisDescriptor = model.YAxes[i];
    5656
    5757        CheckBox chkbox = new CheckBox();
    58         chkbox.Text = row.Label;
    59         chkbox.Checked = row.ShowYAxis;
    60         chkbox.CheckedChanged += delegate { row.ShowYAxis = chkbox.Checked; };
     58        chkbox.Text = yAxisDescriptor.Label;
     59        chkbox.Checked = yAxisDescriptor.ShowYAxis;
     60        chkbox.CheckedChanged += delegate { yAxisDescriptor.ShowYAxis = chkbox.Checked; };
    6161       
    6262        dataRowsFlowLayout.Controls.Add(chkbox);
Note: See TracChangeset for help on using the changeset viewer.