-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDocumentTableStyle.java
More file actions
204 lines (183 loc) · 5.2 KB
/
DocumentTableStyle.java
File metadata and controls
204 lines (183 loc) · 5.2 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
package com.demcha.compose.document.table;
import com.demcha.compose.document.style.DocumentColor;
import com.demcha.compose.document.style.DocumentInsets;
import com.demcha.compose.document.style.DocumentStroke;
import com.demcha.compose.document.style.DocumentTextStyle;
/**
* Public table cell style override for the canonical DSL.
*
* <p>All fields are optional. Missing values inherit from the table defaults,
* column overrides, row overrides, or backend defaults during layout/render.</p>
*
* @author Artem Demchyshyn
*/
public final class DocumentTableStyle {
private final DocumentInsets padding;
private final DocumentColor fillColor;
private final DocumentStroke stroke;
private final DocumentTextStyle textStyle;
private final DocumentTableTextAnchor textAnchor;
private final Double lineSpacing;
private DocumentTableStyle(Builder builder) {
this.padding = builder.padding;
this.fillColor = builder.fillColor;
this.stroke = builder.stroke;
this.textStyle = builder.textStyle;
this.textAnchor = builder.textAnchor;
this.lineSpacing = builder.lineSpacing;
}
/**
* Creates an empty style override.
*
* @return empty table style
*/
public static DocumentTableStyle empty() {
return builder().build();
}
/**
* Starts a mutable table style builder.
*
* @return table style builder
*/
public static Builder builder() {
return new Builder();
}
/**
* Returns optional cell padding.
*
* @return padding override, or {@code null}
*/
public DocumentInsets padding() {
return padding;
}
/**
* Returns optional cell fill color.
*
* @return fill color override, or {@code null}
*/
public DocumentColor fillColor() {
return fillColor;
}
/**
* Returns optional cell border stroke.
*
* @return stroke override, or {@code null}
*/
public DocumentStroke stroke() {
return stroke;
}
/**
* Returns optional cell text style.
*
* @return text style override, or {@code null}
*/
public DocumentTextStyle textStyle() {
return textStyle;
}
/**
* Returns optional text placement anchor.
*
* @return anchor override, or {@code null}
*/
public DocumentTableTextAnchor textAnchor() {
return textAnchor;
}
/**
* Returns optional spacing between wrapped cell lines.
*
* @return line spacing override, or {@code null}
*/
public Double lineSpacing() {
return lineSpacing;
}
/**
* Mutable builder for {@link DocumentTableStyle}.
*/
public static final class Builder {
private DocumentInsets padding;
private DocumentColor fillColor;
private DocumentStroke stroke;
private DocumentTextStyle textStyle;
private DocumentTableTextAnchor textAnchor;
private Double lineSpacing;
private Builder() {
}
/**
* Sets the cell padding override.
*
* @param padding padding value
* @return this builder
*/
public Builder padding(DocumentInsets padding) {
this.padding = padding;
return this;
}
/**
* Sets equal cell padding on all sides.
*
* @param padding padding in points
* @return this builder
*/
public Builder padding(double padding) {
return padding(DocumentInsets.of(padding));
}
/**
* Sets the cell fill color override.
*
* @param fillColor fill color
* @return this builder
*/
public Builder fillColor(DocumentColor fillColor) {
this.fillColor = fillColor;
return this;
}
/**
* Sets the cell border stroke override.
*
* @param stroke border stroke
* @return this builder
*/
public Builder stroke(DocumentStroke stroke) {
this.stroke = stroke;
return this;
}
/**
* Sets the cell text style override.
*
* @param textStyle text style
* @return this builder
*/
public Builder textStyle(DocumentTextStyle textStyle) {
this.textStyle = textStyle;
return this;
}
/**
* Sets the cell text placement anchor.
*
* @param textAnchor text anchor
* @return this builder
*/
public Builder textAnchor(DocumentTableTextAnchor textAnchor) {
this.textAnchor = textAnchor;
return this;
}
/**
* Sets spacing between wrapped cell lines.
*
* @param lineSpacing line spacing in points
* @return this builder
*/
public Builder lineSpacing(double lineSpacing) {
this.lineSpacing = lineSpacing;
return this;
}
/**
* Builds an immutable style override.
*
* @return table style
*/
public DocumentTableStyle build() {
return new DocumentTableStyle(this);
}
}
}