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
use super::*;
pub struct Text {
pub alignment_horizontal: String,
pub alignment_vertical: String,
pub rotation: f64,
pub font_size: f64,
pub(crate) buffer: String,
}
impl Text {
pub fn new() -> Self {
Text {
alignment_horizontal: String::new(),
alignment_vertical: String::new(),
rotation: 0.0,
font_size: 0.0,
buffer: String::new(),
}
}
pub(crate) fn options(&self) -> String {
let mut options = String::new();
if self.alignment_horizontal != "" {
options.push_str(&format!(",ha='{}'", self.alignment_horizontal));
}
if self.alignment_vertical != "" {
options.push_str(&format!(",va='{}'", self.alignment_vertical));
}
if self.rotation > 0.0 {
options.push_str(&format!(",rotation={}", self.rotation));
}
if self.font_size > 0.0 {
options.push_str(&format!(",fontsize={}", self.font_size));
}
options
}
}
impl GraphMaker for Text {
fn get_buffer<'a>(&'a self) -> &'a String {
&self.buffer
}
}