Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/27/09 20:23:17 (15 years ago)
Author:
mstoeger
Message:

Display of X- and Y-Axis-Labels (#556)

Location:
trunk/sources/HeuristicLab.Visualization
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Visualization/ChartDataRowsModel.cs

    r1387 r1462  
    1515  public class ChartDataRowsModel : ChartDataModelBase, IChartDataRowsModel{
    1616    private string title = "Title";
    17     //private string xAxisLabel;
     17    private string xAxisLabel = "";
     18    private bool showXAxisLabel = true;
    1819    private ILabelProvider labelProvider = new ContinuousLabelProvider("0.##");
    1920
     
    5960      }
    6061    }
    61     //public string XAxisLabel {
    62     //  get { return xAxisLabel; }
    63     //  set {
    64     //    xAxisLabel = value;
    65     //    OnModelChanged();
    66     //  }
    67     //}
     62
     63    public string XAxisLabel {
     64      get { return xAxisLabel; }
     65      set {
     66        xAxisLabel = value;
     67        OnModelChanged();
     68      }
     69    }
     70
     71    public bool ShowXAxisLabel {
     72      get { return showXAxisLabel; }
     73      set {
     74        showXAxisLabel = value;
     75        OnModelChanged();
     76      }
     77    }
    6878
    6979    public override IView CreateView() {
  • trunk/sources/HeuristicLab.Visualization/IChartDataRowsModel.cs

    r1350 r1462  
    1919    ViewSettings ViewSettings { get; set; }
    2020
     21    string XAxisLabel { get; set; }
     22    bool ShowXAxisLabel { get; set; }
     23
    2124    event ModelChangedHandler ModelChanged;
    2225    event DataRowAddedHandler DataRowAdded;
  • trunk/sources/HeuristicLab.Visualization/LineChart.cs

    r1459 r1462  
    2727
    2828    private const int YAxisWidth = 100;
    29     private const int XAxisHeight = 20;
     29    private const int XAxisHeight = 40;
    3030
    3131    /// <summary>
     
    9595      }
    9696
     97      xAxis.ShowLabel = model.ShowXAxisLabel;
     98      xAxis.Label = model.XAxisLabel;
     99
    97100      canvas.AddShape(xAxis);
    98101
     
    104107        if (yAxisDescriptor.ShowYAxis) {
    105108          canvas.AddShape(info.YAxis);
     109          info.YAxis.ShowLabel = yAxisDescriptor.ShowYAxisLabel;
     110          info.YAxis.Label = yAxisDescriptor.Label;
    106111          info.YAxis.Position = yAxisDescriptor.Position;
    107112          switch (yAxisDescriptor.Position) {
  • trunk/sources/HeuristicLab.Visualization/TextShape.cs

    r1337 r1462  
    11using System;
    22using System.Drawing;
     3using System.Drawing.Drawing2D;
    34
    45namespace HeuristicLab.Visualization {
     
    1920    private double x;
    2021    private double y;
     22    private float rotation = 0;
    2123
    2224    private AnchorPositionX anchorPositionX = AnchorPositionX.Left;
     
    5961    }
    6062
     63    public float Rotation {
     64      get { return rotation; }
     65      set { rotation = value; }
     66    }
     67
    6168    public Color Color {
    6269      get { return color; }
     
    8794      int screenX = Transform.ToScreenX(x, Parent.Viewport, Parent.ClippingArea);
    8895      int screenY = Transform.ToScreenY(y, Parent.Viewport, Parent.ClippingArea);
     96      int offsetX, offsetY;
    8997
    9098      SizeF size = graphics.MeasureString(text, font);
     
    92100      switch (AnchorPositionX) {
    93101        case AnchorPositionX.Left:
     102          offsetX = 0;
    94103          break;
    95104        case AnchorPositionX.Middle:
    96           screenX -= (int)(size.Width/2);
     105          offsetX = -(int)(size.Width/2);
    97106          break;
    98107        case AnchorPositionX.Right:
    99           screenX -= (int)size.Width;
     108          offsetX = -(int)size.Width;
    100109          break;
    101110        default:
     
    105114      switch (AnchorPositionY) {
    106115        case AnchorPositionY.Top:
     116          offsetY = 0;
    107117          break;
    108118        case AnchorPositionY.Middle:
    109           screenY -= (int)(size.Height/2);
     119          offsetY = -(int)(size.Height/2);
    110120          break;
    111121        case AnchorPositionY.Bottom:
    112           screenY -= (int)size.Height;
     122          offsetY = -(int)size.Height;
    113123          break;
    114124        default:
     
    116126      }
    117127
    118       graphics.DrawString(text, font, brush, screenX, screenY);
     128      GraphicsState gstate = graphics.Save();
     129      graphics.TranslateTransform(screenX, screenY, MatrixOrder.Append);
     130      graphics.RotateTransform(rotation, MatrixOrder.Prepend);
     131      graphics.DrawString(text, font, brush, offsetX, offsetY);
     132      graphics.Restore(gstate);
    119133    }
    120134
  • trunk/sources/HeuristicLab.Visualization/XAxis.cs

    r1337 r1462  
    1010    private Color color = Color.Blue;
    1111    private Font font = new Font("Arial", 8);
     12    private bool showLabel = true;
     13    private string label = "";
    1214
    1315    public ILabelProvider LabelProvider {
     
    2224                                              ClippingArea.Width,
    2325                                              ClippingArea.X1)) {
    24         TextShape label = new TextShape(x, ClippingArea.Height - 3,
     26        TextShape tickLabel = new TextShape(x, ClippingArea.Height - 3,
    2527                                        labelProvider.GetLabel(x), Font, Color);
     28        tickLabel.AnchorPositionX = AnchorPositionX.Middle;
     29        tickLabel.AnchorPositionY = AnchorPositionY.Top;
     30        AddShape(tickLabel);
     31      }
     32
     33      if (showLabel) {
     34        TextShape label = new TextShape(ClippingArea.X1 + ClippingArea.Width/2,
     35                                        ClippingArea.Y1 + 3,
     36                                        this.label);
    2637        label.AnchorPositionX = AnchorPositionX.Middle;
    27         label.AnchorPositionY = AnchorPositionY.Top;
     38        label.AnchorPositionY = AnchorPositionY.Bottom;
     39
    2840        AddShape(label);
    2941      }
     
    4153      set { font = value; }
    4254    }
     55
     56    public bool ShowLabel {
     57      get { return showLabel; }
     58      set { showLabel = value; }
     59    }
     60
     61    public string Label {
     62      get { return label; }
     63      set { label = value; }
     64    }
    4365  }
    4466}
  • trunk/sources/HeuristicLab.Visualization/YAxis.cs

    r1457 r1462  
    1010    private ILabelProvider labelProvider = new ContinuousLabelProvider("e4");
    1111    private AxisPosition position = AxisPosition.Left;
     12    private bool showLabel = true;
     13    private string label = "";
    1214
    1315    public ILabelProvider LabelProvider {
     
    1921      get { return position; }
    2022      set { position = value; }
     23    }
     24
     25    public bool ShowLabel {
     26      get { return showLabel; }
     27      set { showLabel = value; }
     28    }
     29
     30    public string Label {
     31      get { return label; }
     32      set { label = value; }
    2133    }
    2234
     
    4355        }
    4456       
    45         TextShape label = new TextShape(x, y, labelProvider.GetLabel(y));
    46         label.AnchorPositionX = anchorPositionX;
    47         label.AnchorPositionY = AnchorPositionY.Middle;
     57        TextShape tickLabel = new TextShape(x, y, labelProvider.GetLabel(y));
     58        tickLabel.AnchorPositionX = anchorPositionX;
     59        tickLabel.AnchorPositionY = AnchorPositionY.Middle;
     60        AddShape(tickLabel);
     61      }
     62
     63      if (showLabel) {
     64        double x;
     65        AnchorPositionY anchorPositionY;
     66
     67        switch (position) {
     68          case AxisPosition.Left:
     69            x = ClippingArea.X1 + 3;
     70            anchorPositionY = AnchorPositionY.Top;
     71            break;
     72          case AxisPosition.Right:
     73            x = ClippingArea.X2 - 3;
     74            anchorPositionY = AnchorPositionY.Bottom;
     75            break;
     76          default:
     77            throw new NotImplementedException();
     78        }
     79
     80        TextShape label = new TextShape(x,
     81                                        ClippingArea.Y1 + ClippingArea.Height/2,
     82                                        this.label);
     83        label.AnchorPositionX = AnchorPositionX.Middle;
     84        label.AnchorPositionY = anchorPositionY;
     85        label.Rotation = -90;
    4886        AddShape(label);
    4987      }
  • trunk/sources/HeuristicLab.Visualization/YAxisDescriptor.cs

    r1460 r1462  
    1212    private readonly List<IDataRow> dataRows = new List<IDataRow>();
    1313    private bool showYAxis = true;
     14    private bool showYAxisLabel = true;
    1415    private string label = "";
    1516    public bool clipChangeable = true;
     
    3536      set {
    3637        showYAxis = value;
     38        OnYAxisDescriptorChanged();
     39      }
     40    }
     41
     42    public bool ShowYAxisLabel {
     43      get { return showYAxisLabel; }
     44      set {
     45        showYAxisLabel = value;
    3746        OnYAxisDescriptorChanged();
    3847      }
Note: See TracChangeset for help on using the changeset viewer.