Free cookie consent management tool by TermsFeed Policy Generator

Changeset 983


Ignore:
Timestamp:
12/12/08 18:13:12 (16 years ago)
Author:
mstoeger
Message:

Added XAxis shape to project (#433)
Some small refactorings in LineChart (#345)

Location:
trunk/sources
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources

    • Property svn:ignore
      •  

        old new  
        11*.suo
         2_ReSharper.HeuristicLab
         3HeuristicLab.resharper
         4HeuristicLab.resharper.user
  • trunk/sources/HeuristicLab.Visualization.Test/LineChartTests.cs

    r980 r983  
     1using System;
    12using System.Drawing;
    23using NUnit.Framework;
     
    4748      row3.AddValue(2);
    4849
     50      Random rand = new Random();
     51
     52      for (int i = 0; i < 1000; i++) {
     53        row1.AddValue(rand.NextDouble()*10);
     54        row2.AddValue(rand.NextDouble()*10);
     55        row3.AddValue(rand.NextDouble()*10);
     56      }
     57
     58      f.ShowDialog();
     59    }
     60
     61    [Test]
     62    public void TestAxes() {
     63      LineChartTestForm f = new LineChartTestForm();
     64
     65      IDataRow row1 = new DataRow();
     66
     67      row1.Color = Color.Red;
     68      row1.Thickness = 3;
     69      row1.Style = DrawingStyle.Solid;
     70
     71      f.Model.AddDataRow(row1);
     72
     73      row1.AddValue(10);
     74      row1.AddValue(5);
     75      row1.AddValue(7);
     76      row1.AddValue(3);
     77      row1.AddValue(10);
     78      row1.AddValue(2);
     79
    4980      f.ShowDialog();
    5081    }
  • trunk/sources/HeuristicLab.Visualization/HeuristicLab.Visualization.csproj

    r874 r983  
    44    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    55    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    6     <ProductVersion>9.0.21022</ProductVersion>
     6    <ProductVersion>9.0.30729</ProductVersion>
    77    <SchemaVersion>2.0</SchemaVersion>
    88    <ProjectGuid>{E392A1E2-DC95-4E33-B82E-8ED690EDA1AB}</ProjectGuid>
     
    106106    <Compile Include="Transform.cs" />
    107107    <Compile Include="WorldShape.cs" />
     108    <Compile Include="XAxis.cs" />
    108109  </ItemGroup>
    109110  <ItemGroup>
  • trunk/sources/HeuristicLab.Visualization/LineChart.cs

    r981 r983  
    11using System;
    22using System.Collections.Generic;
    3 using System.Diagnostics;
    43using System.Drawing;
    54using System.Windows.Forms;
     
    1413    private double maxDataValue;
    1514
     15    private readonly WorldShape root;
     16    private readonly XAxis xAxis;
     17
    1618    /// <summary>
    1719    /// This constructor shouldn't be called. Only required for the designer.
     
    3234      //TODO: correct Rectangle to fit
    3335      RectangleD clientRectangle = new RectangleD(-1, -1, 1, 1);
    34       canvasUI1.MainCanvas.WorldShape = new WorldShape(clientRectangle, clientRectangle);
     36
     37      root = new WorldShape(clientRectangle, clientRectangle);
     38
     39      xAxis = new XAxis();
     40      root.AddShape(xAxis);
     41
     42      canvasUI1.MainCanvas.WorldShape = root;
    3543         
    3644      CreateMouseEventListeners();
    3745         
    3846      this.model = model;
    39       Item = (IItem)model;
     47      Item = model;
    4048      maxDataRowCount = 0;
    4149      //The whole data rows are shown per default
     
    8492        maxDataRowCount-0.9,
    8593        maxDataValue + ((maxDataValue - minDataValue) * 0.05));
    86       canvasUI1.MainCanvas.WorldShape.ClippingArea = newClippingArea;
     94      root.ClippingArea = newClippingArea;
    8795    }
    8896
     
    92100      List<LineShape> lineShapes = new List<LineShape>();
    93101      if (row.Count > 0) {
    94         maxDataValue = Max(row[0], this.maxDataValue);
    95         minDataValue = Min(row[0], minDataValue);
     102        maxDataValue = Math.Max(row[0], this.maxDataValue);
     103        minDataValue = Math.Min(row[0], minDataValue);
    96104      }
    97105      for (int i = 1; i < row.Count; i++) {
     
    99107        lineShapes.Add(lineShape);
    100108        // TODO each DataRow needs its own WorldShape so Y Axes can be zoomed independently.
    101         canvasUI1.MainCanvas.WorldShape.AddShape(lineShape);
    102         maxDataValue = Max(row[i], maxDataValue);
    103         minDataValue = Min(row[i], minDataValue);
     109        root.AddShape(lineShape);
     110        maxDataValue = Math.Max(row[i], maxDataValue);
     111        minDataValue = Math.Min(row[i], minDataValue);
    104112      }
    105113
     
    109117    }
    110118
    111     private double Min(double d, double value) {
    112       return d < value ? d : value;
    113     }
    114 
    115     private double Max(double d, double value) {
    116       return d>value ? d : value;
    117     }
    118 
    119119    private void OnDataRowRemoved(IDataRow row) {
    120120      row.ValueChanged -= OnRowValueChanged;
     
    127127    private void OnRowValueChanged(IDataRow row, double value, int index, Action action) {
    128128      List<LineShape> lineShapes = rowToLineShapes[row];
    129       maxDataValue = Max(value, maxDataValue);
    130       minDataValue = Min(value, minDataValue);
     129      maxDataValue = Math.Max(value, maxDataValue);
     130      minDataValue = Math.Min(value, minDataValue);
    131131
    132132      if (index > lineShapes.Count + 1) {
     
    206206      canvasUI1.MouseEventListener = panListener;
    207207
    208       startClippingArea = canvasUI1.MainCanvas.WorldShape.ClippingArea;
     208      startClippingArea = root.ClippingArea;
    209209    }
    210210
     
    228228      newClippingArea.Y2 = startClippingArea.Y2 - yDiff;
    229229
    230       canvasUI1.MainCanvas.WorldShape.ClippingArea = newClippingArea;
     230      root.ClippingArea = newClippingArea;
    231231      panListener.StartPoint = startPoint;
    232232
Note: See TracChangeset for help on using the changeset viewer.