-
Notifications
You must be signed in to change notification settings - Fork 976
Expand file tree
/
Copy pathTextualAnnotation.cs
More file actions
81 lines (71 loc) · 3.04 KB
/
Copy pathTextualAnnotation.cs
File metadata and controls
81 lines (71 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="TextualAnnotation.cs" company="OxyPlot">
// Copyright (c) 2014 OxyPlot contributors
// </copyright>
// <summary>
// Provides an abstract base class for annotations that contains text.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
#nullable enable
namespace OxyPlot.Annotations
{
using System;
/// <summary>
/// Provides an abstract base class for annotations that contains text.
/// </summary>
public abstract class TextualAnnotation : TransposableAnnotation
{
/// <summary>
/// Initializes a new instance of the <see cref="TextualAnnotation"/> class.
/// </summary>
protected TextualAnnotation()
{
this.TextHorizontalAlignment = HorizontalAlignment.Center;
this.TextVerticalAlignment = VerticalAlignment.Middle;
this.TextPosition = DataPoint.Undefined;
this.TextRotation = 0;
}
/// <summary>
/// Gets or sets the annotation text.
/// </summary>
/// <value>The text.</value>
public string? Text { get; set; }
/// <summary>
/// Gets or sets the position of the text.
/// </summary>
/// <remarks>If the value is <c>DataPoint.Undefined</c>, the default position of the text will be used.</remarks>
public DataPoint TextPosition { get; set; }
/// <summary>
/// Gets or sets the horizontal alignment of the text.
/// </summary>
public HorizontalAlignment TextHorizontalAlignment { get; set; }
/// <summary>
/// Gets or sets the vertical alignment of the text.
/// </summary>
public VerticalAlignment TextVerticalAlignment { get; set; }
/// <summary>
/// Gets or sets the rotation of the text.
/// </summary>
/// <value>The text rotation in degrees.</value>
public double TextRotation { get; set; }
/// <summary>
/// Gets the actual position of the text.
/// </summary>
/// <param name="defaultPosition">A function that returns the default position. This is used if <see cref="TextPosition" /> is undefined.</param>
/// <returns>The actual position of the text, in screen space.</returns>
protected ScreenPoint GetActualTextPosition(Func<ScreenPoint> defaultPosition)
{
return this.TextPosition.IsDefined() ? this.Transform(this.TextPosition) : defaultPosition();
}
/// <summary>
/// Gets the actual text alignment.
/// </summary>
/// <param name="ha">The horizontal alignment.</param>
/// <param name="va">The vertical alignment.</param>
protected void GetActualTextAlignment(out HorizontalAlignment ha, out VerticalAlignment va)
{
ha = this.TextHorizontalAlignment;
va = this.TextVerticalAlignment;
}
}
}