|
16 | 16 | package software.xdev.chartjs.model.options; |
17 | 17 |
|
18 | 18 | import software.xdev.chartjs.model.color.Color; |
19 | | -import software.xdev.chartjs.model.enums.FontStyle; |
20 | | -import software.xdev.chartjs.model.enums.TitlePosition; |
| 19 | +import software.xdev.chartjs.model.options.scales.Font; |
21 | 20 |
|
22 | 21 |
|
23 | 22 | public class Title |
24 | 23 | { |
| 24 | + protected String align; |
| 25 | + protected Color color; |
25 | 26 | protected Boolean display; |
26 | | - protected TitlePosition position; |
27 | | - protected Boolean fullWidth; |
28 | | - protected Integer fontSize; |
29 | | - protected String fontFamily; |
30 | | - protected Color fontColor; |
31 | | - protected FontStyle fontStyle; |
| 27 | + protected Boolean fullSize; |
| 28 | + protected String position; |
| 29 | + protected Font font; |
32 | 30 | protected Integer padding; |
33 | 31 | protected String text; |
34 | 32 |
|
35 | 33 | /** |
36 | | - * @see #setDisplay(Boolean) |
37 | | - */ |
38 | | - public Boolean getDisplay() |
39 | | - { |
40 | | - return this.display; |
41 | | - } |
42 | | - |
43 | | - /** |
44 | | - * <p> |
45 | | - * Display the title block |
46 | | - * </p> |
47 | | - * |
48 | | - * <p> |
49 | | - * Default {@code false} |
50 | | - * </p> |
| 34 | + * @see #setAlign(String) |
51 | 35 | */ |
52 | | - public Title setDisplay(final Boolean display) |
| 36 | + public String getAlign() |
53 | 37 | { |
54 | | - this.display = display; |
55 | | - return this; |
| 38 | + return this.align; |
56 | 39 | } |
57 | 40 |
|
58 | 41 | /** |
59 | | - * @see #setPosition(TitlePosition) |
60 | | - */ |
61 | | - public TitlePosition getPosition() |
62 | | - { |
63 | | - return this.position; |
64 | | - } |
65 | | - |
66 | | - /** |
67 | | - * <p> |
68 | | - * Position of the title. Only 'top' or 'bottom' are currently allowed |
69 | | - * </p> |
| 42 | + * Alignment of the title |
70 | 43 | * |
71 | | - * <p> |
72 | | - * Default {@code 'top'} |
73 | | - * </p> |
| 44 | + * <p>Default: center</p> |
74 | 45 | */ |
75 | | - public Title setPosition(final TitlePosition position) |
| 46 | + public Title setAlign(final String align) |
76 | 47 | { |
77 | | - this.position = position; |
| 48 | + this.align = align; |
78 | 49 | return this; |
79 | 50 | } |
80 | 51 |
|
81 | 52 | /** |
82 | | - * @see #setFullWidth(Boolean) |
| 53 | + * @see #setColor(Color) |
83 | 54 | */ |
84 | | - public Boolean getFullWidth() |
| 55 | + public Color getColor() |
85 | 56 | { |
86 | | - return this.fullWidth; |
| 57 | + return this.color; |
87 | 58 | } |
88 | 59 |
|
89 | 60 | /** |
90 | | - * <p> |
91 | | - * Marks that this box should take the full width of the canvas (pushing down other boxes) |
92 | | - * </p> |
93 | | - * |
94 | | - * <p> |
95 | | - * Default {@code true} |
96 | | - * </p> |
| 61 | + * Color of text |
97 | 62 | */ |
98 | | - public Title setFullWidth(final Boolean fullWidth) |
| 63 | + public Title setColor(final Color color) |
99 | 64 | { |
100 | | - this.fullWidth = fullWidth; |
| 65 | + this.color = color; |
101 | 66 | return this; |
102 | 67 | } |
103 | 68 |
|
104 | 69 | /** |
105 | | - * @see #setFontSize(Integer) |
| 70 | + * @see #setFullSize(Boolean) |
106 | 71 | */ |
107 | | - public Integer getFontSize() |
| 72 | + public Boolean getFullSize() |
108 | 73 | { |
109 | | - return this.fontSize; |
| 74 | + return this.fullSize; |
110 | 75 | } |
111 | 76 |
|
112 | 77 | /** |
113 | | - * <p> |
114 | | - * Font size inherited from global configuration |
115 | | - * </p> |
| 78 | + * Marks that this box should take the full width/height of the canvas. If false, the box is sized and placed |
| 79 | + * above/beside the chart area. |
116 | 80 | * |
117 | | - * <p> |
118 | | - * Default {@code 12} |
119 | | - * </p> |
| 81 | + * <p>Default: true</p> |
120 | 82 | */ |
121 | | - public Title setFontSize(final Integer fontSize) |
| 83 | + public Title setFullSize(final Boolean fullSize) |
122 | 84 | { |
123 | | - this.fontSize = fontSize; |
| 85 | + this.fullSize = fullSize; |
124 | 86 | return this; |
125 | 87 | } |
126 | 88 |
|
127 | | - /** |
128 | | - * @see #setFontFamily(String) |
129 | | - */ |
130 | | - public String getFontFamily() |
| 89 | + public Font getFont() |
131 | 90 | { |
132 | | - return this.fontFamily; |
| 91 | + return this.font; |
133 | 92 | } |
134 | 93 |
|
135 | | - /** |
136 | | - * <p> |
137 | | - * Font family inherited from global configuration |
138 | | - * </p> |
139 | | - * |
140 | | - * <p> |
141 | | - * Default {@code "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"} |
142 | | - * </p> |
143 | | - */ |
144 | | - public Title setFontFamily(final String fontFamily) |
| 94 | + public Title setFont(final Font font) |
145 | 95 | { |
146 | | - this.fontFamily = fontFamily; |
| 96 | + this.font = font; |
147 | 97 | return this; |
148 | 98 | } |
149 | 99 |
|
150 | 100 | /** |
151 | | - * @see #setFontColor(Color) |
| 101 | + * @see #setDisplay(Boolean) |
152 | 102 | */ |
153 | | - public Color getFontColor() |
| 103 | + public Boolean getDisplay() |
154 | 104 | { |
155 | | - return this.fontColor; |
| 105 | + return this.display; |
156 | 106 | } |
157 | 107 |
|
158 | 108 | /** |
159 | 109 | * <p> |
160 | | - * Font color inherited from global configuration |
| 110 | + * Display the title block |
161 | 111 | * </p> |
162 | 112 | * |
163 | 113 | * <p> |
164 | | - * Default {@code "#666"} |
| 114 | + * Default {@code false} |
165 | 115 | * </p> |
166 | 116 | */ |
167 | | - public Title setFontColor(final Color fontColor) |
| 117 | + public Title setDisplay(final Boolean display) |
168 | 118 | { |
169 | | - this.fontColor = fontColor; |
| 119 | + this.display = display; |
170 | 120 | return this; |
171 | 121 | } |
172 | 122 |
|
173 | 123 | /** |
174 | | - * @see #setFontStyle(FontStyle) |
| 124 | + * @see #setPosition(String) |
175 | 125 | */ |
176 | | - public FontStyle getFontStyle() |
| 126 | + public String getPosition() |
177 | 127 | { |
178 | | - return this.fontStyle; |
| 128 | + return this.position; |
179 | 129 | } |
180 | 130 |
|
181 | 131 | /** |
182 | 132 | * <p> |
183 | | - * Font styling of the title, follows CSS font-style options (i.e. normal, italic, oblique, initial, inherit). |
| 133 | + * Position of the title. Only 'top' or 'bottom' are currently allowed |
184 | 134 | * </p> |
185 | 135 | * |
186 | 136 | * <p> |
187 | | - * Default {@code 'bold'} |
| 137 | + * Default {@code 'top'} |
188 | 138 | * </p> |
189 | 139 | */ |
190 | | - public Title setFontStyle(final FontStyle fontStyle) |
| 140 | + public Title setPosition(final String position) |
191 | 141 | { |
192 | | - this.fontStyle = fontStyle; |
| 142 | + this.position = position; |
193 | 143 | return this; |
194 | 144 | } |
195 | 145 |
|
|
0 commit comments