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)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.