-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathSpacerBuilder.java
More file actions
116 lines (105 loc) · 2.76 KB
/
Copy pathSpacerBuilder.java
File metadata and controls
116 lines (105 loc) · 2.76 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
package com.demcha.compose.document.dsl;
import com.demcha.compose.document.node.SpacerNode;
import com.demcha.compose.document.style.DocumentInsets;
/**
* Builder for invisible fixed-size spacer nodes.
*
* @author Artem Demchyshyn
* @since 1.0.0
*/
public final class SpacerBuilder {
private String name = "";
private double width;
private double height;
private DocumentInsets padding = DocumentInsets.zero();
private DocumentInsets margin = DocumentInsets.zero();
private double grow;
/**
* Creates a spacer builder.
*/
public SpacerBuilder() {
}
/**
* Sets the spacer node name.
*
* @param name name used in snapshots and layout graph paths
* @return this builder
*/
public SpacerBuilder name(String name) {
this.name = name == null ? "" : name;
return this;
}
/**
* Sets spacer width.
*
* @param width width in points
* @return this builder
*/
public SpacerBuilder width(double width) {
this.width = width;
return this;
}
/**
* Sets spacer height.
*
* @param height height in points
* @return this builder
*/
public SpacerBuilder height(double height) {
this.height = height;
return this;
}
/**
* Sets spacer width and height.
*
* @param width width in points
* @param height height in points
* @return this builder
*/
public SpacerBuilder size(double width, double height) {
this.width = width;
this.height = height;
return this;
}
/**
* Sets the flex grow factor. Inside a row, a spacer with {@code grow > 0}
* becomes a spring that absorbs a share of the row's leftover width
* proportional to its grow factor; {@code 0} (the default) is rigid.
*
* @param grow grow factor; must be finite and {@code >= 0}
* @return this builder
* @since 1.9.0
*/
public SpacerBuilder grow(double grow) {
this.grow = grow;
return this;
}
/**
* Sets spacer padding.
*
* @param padding padding in points
* @return this builder
*/
public SpacerBuilder padding(DocumentInsets padding) {
this.padding = padding == null ? DocumentInsets.zero() : padding;
return this;
}
/**
* Sets spacer margin.
*
* @param margin margin in points
* @return this builder
*/
public SpacerBuilder margin(DocumentInsets margin) {
this.margin = margin == null ? DocumentInsets.zero() : margin;
return this;
}
/**
* Builds the spacer node.
*
* @return spacer node
*/
public SpacerNode build() {
return new SpacerNode(name, width, height, padding, margin, grow);
}
}