Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/23/09 10:19:25 (15 years ago)
Author:
mstoeger
Message:

Moved X-Axis settings from model to model.XAxis. Fixed UpdateLayout and invalidating. #498

Location:
trunk/sources/HeuristicLab.Visualization/3.2
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Visualization/3.2/CanvasUI.cs

    r1530 r1880  
    1818    }
    1919
     20    public event PaintEventHandler BeforePaint;
     21
    2022    protected override void OnPaint(PaintEventArgs pe) {
    2123      try {
     24        FireBeforePaint(pe);
     25
    2226        Graphics g = pe.Graphics;
    2327
     
    3842      base.OnResize(e);
    3943    }
     44
     45    private void FireBeforePaint(PaintEventArgs e) {
     46      if (BeforePaint != null)
     47        BeforePaint(this, e);
     48    }
    4049  }
    4150}
  • trunk/sources/HeuristicLab.Visualization/3.2/ChartDataRowsModel.cs

    r1876 r1880  
    55using HeuristicLab.Core;
    66using System.Text;
    7 using HeuristicLab.Visualization.LabelProvider;
    87using HeuristicLab.Visualization.Options;
    98
     
    1514  public class ChartDataRowsModel : ChartDataModelBase, IChartDataRowsModel{
    1615    private string title = "Title";
    17     private string xAxisLabel = "";
    18     private bool showXAxisLabel = true;
    19     private bool showXAxisGrid = true;
    20     private ILabelProvider labelProvider = new ContinuousLabelProvider("0.##");
    2116
    2217    private ViewSettings viewSettings = new ViewSettings();
    2318
    24     public bool ShowXAxisGrid {
    25       get { return showXAxisGrid; }
    26       set {
    27         this.showXAxisGrid = value;
    28         OnModelChanged();
    29       }
     19    private readonly XAxisDescriptor xAxisDescriptor = new XAxisDescriptor();
     20
     21    public ChartDataRowsModel() {
     22      this.XAxis.XAxisDescriptorChanged += delegate { OnModelChanged(); };
    3023    }
    3124
    32     public ILabelProvider XAxisLabelProvider {
    33       get { return labelProvider; }
    34       set{
    35         this.labelProvider = value;
    36         OnModelChanged();
    37       }
     25    public XAxisDescriptor XAxis {
     26      get { return xAxisDescriptor; }
    3827    }
    3928
     
    5241
    5342    private readonly List<IDataRow> rows = new List<IDataRow>();
    54     //private readonly List<string> xLabels = new List<string>();
    55 
    56     //public List<string> XLabels{
    57     //  get { return xLabels; }
    58     //}
    5943
    6044    public List<IDataRow> Rows{
     
    7054    }
    7155
    72     public string XAxisLabel {
    73       get { return xAxisLabel; }
    74       set {
    75         xAxisLabel = value;
    76         OnModelChanged();
    77       }
    78     }
    79 
    80     public bool ShowXAxisLabel {
    81       get { return showXAxisLabel; }
    82       set {
    83         showXAxisLabel = value;
    84         OnModelChanged();
    85       }
    86     }
    87 
    8856    public override IView CreateView() {
    8957      return new LineChart(this);
    9058    }
    91 
    92     //public void AddLabel(string label) {
    93     //  xLabels.Add(label);
    94     //  OnModelChanged();
    95     //}
    96 
    97     //public void AddLabel(string label, int index) {
    98     //  xLabels[index] = label;
    99     //  OnModelChanged();
    100     //}
    101 
    102     //public void AddLabels(string[] labels) {
    103     //  foreach (var s in labels){
    104     //    AddLabel(s);
    105     //  }
    106     //  //OnModelChanged();
    107     //}
    108 
    109     //public void AddLabels(string[] labels, int index) {
    110     //  int i = 0;
    111     //  foreach (var s in labels){
    112     //    AddLabel(s, index + i);
    113     //    i++;
    114     //  }
    115     //  //OnModelChanged();
    116     //}
    117 
    118     //public void ModifyLabel(string label, int index) {
    119     //  xLabels[index] = label;
    120     //  OnModelChanged();
    121     //}
    122 
    123     //public void ModifyLabels(string[] labels, int index) {
    124     //  int i = 0;
    125     //  foreach (var s in labels){
    126     //    ModifyLabel(s, index + i);
    127     //    i++;
    128     //  }
    129     //  //OnModelChanged();
    130     //}
    131 
    132     //public void RemoveLabel(int index) {
    133     //  xLabels.RemoveAt(index);
    134     //  OnModelChanged();
    135     //}
    136 
    137     //public void RemoveLabels(int index, int count) {
    138     //  for (int i = index; i < index + count; i++ ){
    139     //    RemoveLabel(i);
    140     //  }
    141     //  //OnModelChanged();
    142     //}
    14359
    14460    private readonly YAxisDescriptor defaultYAxisDescriptor = new YAxisDescriptor();
     
    228144      }
    229145
    230       XmlNode labelProviderNode = document.ImportNode(labelProvider.GetLabelProviderXmlNode(), true);
     146      XmlNode labelProviderNode = document.ImportNode(XAxis.XAxisLabelProvider.GetLabelProviderXmlNode(), true);
    231147      node.AppendChild(labelProviderNode);
    232148
     
    239155      foreach (XmlNode dataRow in node.ChildNodes) {
    240156        if (dataRow.Name.Equals("LabelProvider")) {
    241           labelProvider = labelProvider.PopulateLabelProviderXmlNode(dataRow);
     157          XAxis.XAxisLabelProvider = XAxis.XAxisLabelProvider.PopulateLabelProviderXmlNode(dataRow);
    242158        } else {
    243159          XmlAttributeCollection attrs = dataRow.Attributes;
  • trunk/sources/HeuristicLab.Visualization/3.2/DataExport/CSVDataExport.cs

    r1781 r1880  
    2727
    2828        // write headers
    29         writer.AddString(model.XAxisLabel);
     29        writer.AddString(model.XAxis.XAxisLabel);
    3030        foreach (IDataRow row in model.Rows)
    3131          writer.AddString(row.Label);
  • trunk/sources/HeuristicLab.Visualization/3.2/HeuristicLab.Visualization-3.2.csproj

    r1876 r1880  
    115115    <Compile Include="LabelProvider\ContinuousLabelProvider.cs" />
    116116    <Compile Include="LabelProvider\DiscreteLabelProvider.cs" />
     117    <Compile Include="XAxisDescriptor.cs" />
    117118    <Compile Include="YAxisGrid.cs" />
    118119    <Compile Include="HorizontalLineShape.cs" />
  • trunk/sources/HeuristicLab.Visualization/3.2/IChartDataRowsModel.cs

    r1876 r1880  
    88    string Title { get; set; }
    99    List<IDataRow> Rows { get; }
    10     ILabelProvider XAxisLabelProvider { get; set; }
    1110
     11    XAxisDescriptor XAxis { get; }
    1212    List<YAxisDescriptor> YAxes { get; }
    1313
     
    1919    ViewSettings ViewSettings { get; set; }
    2020
    21     string XAxisLabel { get; set; }
    22     bool ShowXAxisLabel { get; set; }
    23     bool ShowXAxisGrid { get; set; }
    24 
    2521    event ModelChangedHandler ModelChanged;
    2622    event DataRowAddedHandler DataRowAdded;
  • trunk/sources/HeuristicLab.Visualization/3.2/LineChart.cs

    r1879 r1880  
    5858      this.ResizeRedraw = true;
    5959
     60      canvasUI.BeforePaint += delegate { UpdateLayout(); };
     61
    6062      UpdateLayout();
    6163      ZoomToFullView();
     
    7880      SetLegendPosition();
    7981
    80       this.Invalidate(true);
     82      canvasUI.Invalidate();
    8183    }
    8284
     
    8991      titleShape.Text = model.Title;
    9092
    91       if (model.ShowXAxisGrid) {
     93      if (model.XAxis.ShowXAxisGrid) {
    9294        canvas.AddShape(xAxisGrid);
    9395      }
     
    105107      }
    106108
    107       xAxis.ShowLabel = model.ShowXAxisLabel;
    108       xAxis.Label = model.XAxisLabel;
     109      xAxis.ShowLabel = model.XAxis.ShowXAxisLabel;
     110      xAxis.Label = model.XAxis.XAxisLabel;
    109111
    110112      canvas.AddShape(xAxis);
     
    246248      legendShape.CreateLegend();
    247249
    248       this.Invalidate(true);
     250      canvasUI.Invalidate();
    249251    }
    250252
     
    287289      rowEntry.LinesShape.UpdateStyle(row);
    288290
    289       this.Invalidate(true);
     291      canvasUI.Invalidate();
    290292    }
    291293
     
    322324      InitLineShapes(row);
    323325
    324       this.Invalidate(true);
     326      canvasUI.Invalidate();
    325327    }
    326328
     
    333335      rowEntries.RemoveAll(delegate(RowEntry rowEntry) { return rowEntry.DataRow == row; });
    334336
    335       this.Invalidate(true);
     337      canvasUI.Invalidate();
    336338    }
    337339
     
    349351      }
    350352
    351       this.Invalidate(true);
     353      canvasUI.Invalidate();
    352354    }
    353355
     
    484486
    485487    private void OnModelChanged() {
    486       this.Invalidate(true);
     488      canvasUI.Invalidate();
    487489    }
    488490
     
    503505
    504506      if (beginUpdateCount == 0) {
    505         this.Invalidate(true);
     507        canvasUI.Invalidate();
    506508      }
    507509    }
     
    523525      }
    524526
    525       this.Invalidate(true);
     527      canvasUI.Invalidate();
    526528    }
    527529
     
    544546
    545547      userInteractionShape.RemoveShape(rectangleShape);
    546       this.Invalidate(true);
     548      canvasUI.Invalidate();
    547549    }
    548550
    549551    private void DrawRectangle(Rectangle rectangle) {
    550552      rectangleShape.Rectangle = Transform.ToWorld(rectangle, userInteractionShape.Viewport, userInteractionShape.ClippingArea);
    551       this.Invalidate(true);
     553      canvasUI.Invalidate();
    552554    }
    553555
     
    615617        }
    616618
    617         this.Invalidate(true);
     619        canvasUI.Invalidate();
    618620      }
    619621    }
  • trunk/sources/HeuristicLab.Visualization/3.2/Options/Options.cs

    r1876 r1880  
    6666
    6767    public void ResetSettings() {
    68       model.ShowXAxisGrid = oldShowXAxisGrid;
     68      model.XAxis.ShowXAxisGrid = oldShowXAxisGrid;
    6969
    7070      foreach (var param in oldLineParams) {
     
    102102    }
    103103
    104     private IList<int> GetThicknesses() {
     104    private static IList<int> GetThicknesses() {
    105105      return new List<int>(new[] {1, 2, 3, 4, 5, 6, 7, 8});
    106106    }
    107107
    108     private IList<DrawingStyle> GetStyles() {
     108    private static IList<DrawingStyle> GetStyles() {
    109109      return new List<DrawingStyle>(new[] {DrawingStyle.Solid, DrawingStyle.Dashed});
    110110    }
     
    153153
    154154    private void Options_Load(object sender, EventArgs e) {
    155       oldShowXAxisGrid = model.ShowXAxisGrid;
    156       chkShowXAxisGrid.Checked = model.ShowXAxisGrid;
     155      oldShowXAxisGrid = model.XAxis.ShowXAxisGrid;
     156      chkShowXAxisGrid.Checked = model.XAxis.ShowXAxisGrid;
    157157
    158158      InitTabPageLines();
     
    245245
    246246    private void chkShowXAxisGrid_CheckedChanged(object sender, EventArgs e) {
    247       model.ShowXAxisGrid = chkShowXAxisGrid.Checked;
     247      model.XAxis.ShowXAxisGrid = chkShowXAxisGrid.Checked;
    248248    }
    249249
  • trunk/sources/HeuristicLab.Visualization/3.2/Options/OptionsDialog.Designer.cs

    r1586 r1880  
    6060      //
    6161      this.options.Location = new System.Drawing.Point(2, 3);
    62       chartDataRowsModel1.ShowXAxisLabel = true;
     62      chartDataRowsModel1.XAxis.ShowXAxisLabel = true;
    6363      chartDataRowsModel1.Title = "Title";
    6464      viewSettings1.LegendColor = System.Drawing.Color.Blue;
     
    7070      viewSettings1.XAxisFont = new System.Drawing.Font("Arial", 8F);
    7171      chartDataRowsModel1.ViewSettings = viewSettings1;
    72       chartDataRowsModel1.XAxisLabel = "";
    73       chartDataRowsModel1.XAxisLabelProvider = continuousLabelProvider1;
     72      chartDataRowsModel1.XAxis.XAxisLabel = "";
     73      chartDataRowsModel1.XAxis.XAxisLabelProvider = continuousLabelProvider1;
    7474      this.options.Model = chartDataRowsModel1;
    7575      this.options.Name = "options";
Note: See TracChangeset for help on using the changeset viewer.