@@ -36,17 +36,19 @@ class_scales_list <- S7::new_S3_class("ScalesList")
36
36
# ' @keywords internal
37
37
# ' @export
38
38
class_theme <- S7 :: new_class(
39
- " theme " , class_S3_gg ,
39
+ " class_theme " , class_S3_gg ,
40
40
properties = list (
41
41
complete = S7 :: class_logical ,
42
42
validate = S7 :: class_logical
43
43
),
44
44
constructor = function (elements , complete , validate ) {
45
- S7 :: new_object(
45
+ out <- S7 :: new_object(
46
46
elements ,
47
47
complete = complete ,
48
48
validate = validate
49
49
)
50
+ class(out ) <- c(" theme" , class(out ))
51
+ out
50
52
}
51
53
)
52
54
@@ -61,8 +63,12 @@ class_theme <- S7::new_class(
61
63
# ' @keywords internal
62
64
# ' @export
63
65
class_labels <- S7 :: new_class(
64
- " labels" , parent = class_S3_gg ,
65
- constructor = function (labels ) S7 :: new_object(labels ),
66
+ " class_labels" , parent = class_S3_gg ,
67
+ constructor = function (labels ) {
68
+ out <- S7 :: new_object(labels )
69
+ class(out ) <- c(" labels" , class(out ))
70
+ out
71
+ },
66
72
validator = function (self ) {
67
73
if (! is.list(self )) {
68
74
return (" labels must be a list." )
@@ -91,12 +97,12 @@ class_labels <- S7::new_class(
91
97
# ' @keywords internal
92
98
# ' @export
93
99
class_mapping <- S7 :: new_class(
94
- " mapping " , parent = class_S3_gg ,
100
+ " class_mapping " , parent = class_S3_gg ,
95
101
constructor = function (x , env = globalenv()) {
96
102
check_object(x , is.list , " a {.cls list}" )
97
103
x <- lapply(x , new_aesthetic , env = env )
98
104
x <- S7 :: new_object(x )
99
- class(x ) <- union(c(" ggplot2::mapping" , " uneval" ), class(x ))
105
+ class(x ) <- union(c(" ggplot2::mapping" , " uneval" , " mapping " ), class(x ))
100
106
x
101
107
}
102
108
)
@@ -125,7 +131,7 @@ class_mapping <- S7::new_class(
125
131
# ' @keywords internal
126
132
# ' @export
127
133
class_ggplot <- S7 :: new_class(
128
- name = " ggplot " , parent = class_gg ,
134
+ name = " class_ggplot " , parent = class_gg ,
129
135
properties = list (
130
136
data = S7 :: class_any ,
131
137
layers = S7 :: class_list ,
@@ -146,7 +152,7 @@ class_ggplot <- S7::new_class(
146
152
facet = facet_null(), layout = NULL ,
147
153
labels = labs(), meta = list (),
148
154
plot_env = parent.frame()) {
149
- S7 :: new_object(
155
+ out <- S7 :: new_object(
150
156
S7 :: S7_object(),
151
157
data = data ,
152
158
layers = layers ,
@@ -161,6 +167,8 @@ class_ggplot <- S7::new_class(
161
167
meta = meta ,
162
168
plot_env = plot_env
163
169
)
170
+ class(out ) <- c(" ggplot" , class(out ))
171
+ out
164
172
}
165
173
)
166
174
@@ -179,7 +187,7 @@ class_ggplot <- S7::new_class(
179
187
# ' @keywords internal
180
188
# ' @export
181
189
class_ggplot_built <- S7 :: new_class(
182
- " ggplot_built " , parent = class_gg ,
190
+ " class_ggplot_built " , parent = class_gg ,
183
191
properties = list (
184
192
data = S7 :: class_list ,
185
193
layout = class_layout ,
@@ -191,9 +199,11 @@ class_ggplot_built <- S7::new_class(
191
199
" The {.cls ggplot_built} class should be constructed by {.fn ggplot_build}."
192
200
)
193
201
}
194
- S7 :: new_object(
202
+ out <- S7 :: new_object(
195
203
S7 :: S7_object(),
196
204
data = data , layout = layout , plot = plot
197
205
)
206
+ class(out ) <- c(" ggplot_built" , class(out ))
207
+ out
198
208
}
199
209
)
0 commit comments