Skip to content

Commit 2efa829

Browse files
committed
remove draw_element() in favour of element_grob()
1 parent 1fda7a9 commit 2efa829

File tree

3 files changed

+10
-25
lines changed

3 files changed

+10
-25
lines changed

NAMESPACE

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ S3method(autolayer,default)
2929
S3method(autoplot,default)
3030
S3method(c,mapped_discrete)
3131
S3method(drawDetails,zeroGrob)
32-
S3method(element_grob,default)
3332
S3method(format,ggproto)
3433
S3method(format,ggproto_method)
3534
S3method(format,rd_section_aesthetics)
@@ -318,7 +317,6 @@ export(cut_width)
318317
export(datetime_scale)
319318
export(derive)
320319
export(discrete_scale)
321-
export(draw_element)
322320
export(draw_key_abline)
323321
export(draw_key_blank)
324322
export(draw_key_boxplot)

R/theme-elements.R

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -463,11 +463,13 @@ element_render <- function(theme, element, ..., name = NULL) {
463463
#' usually at least position. See the source code for individual methods.
464464
#' @keywords internal
465465
#' @export
466-
draw_element <- S7::new_generic("draw_element", "element")
466+
element_grob <- function(element, ...) {
467+
UseMethod("element_grob")
468+
}
467469

468-
S7::method(draw_element, element_blank) <- function(element, ...) zeroGrob()
470+
S7::method(element_grob, element_blank) <- function(element, ...) zeroGrob()
469471

470-
S7::method(draw_element, element_rect) <-
472+
S7::method(element_grob, element_rect) <-
471473
function(element, x = 0.5, y = 0.5, width = 1, height = 1,
472474
fill = NULL, colour = NULL,
473475
linewidth = NULL, linetype = NULL, linejoin = NULL,
@@ -486,7 +488,7 @@ S7::method(draw_element, element_rect) <-
486488
rectGrob(x, y, width, height, gp = modify_list(element_gp, gp), ...)
487489
}
488490

489-
S7::method(draw_element, element_text) <-
491+
S7::method(element_grob, element_text) <-
490492
function(element, label = "", x = NULL, y = NULL,
491493
family = NULL, face = NULL, colour = NULL, size = NULL,
492494
hjust = NULL, vjust = NULL, angle = NULL, lineheight = NULL,
@@ -519,7 +521,7 @@ S7::method(draw_element, element_text) <-
519521
margin_x = margin_x, margin_y = margin_y, debug = element@debug, ...)
520522
}
521523

522-
S7::method(draw_element, element_line) <-
524+
S7::method(element_grob, element_line) <-
523525
function(element, x = 0:1, y = 0:1,
524526
colour = NULL, linewidth = NULL, linetype = NULL, lineend = NULL,
525527
linejoin = NULL, arrow.fill = NULL,
@@ -558,7 +560,7 @@ S7::method(draw_element, element_line) <-
558560
)
559561
}
560562

561-
S7::method(draw_element, element_polygon) <-
563+
S7::method(element_grob, element_polygon) <-
562564
function(element, x = c(0, 0.5, 1, 0.5),
563565
y = c(0.5, 1, 0.5, 0), fill = NULL,
564566
colour = NULL, linewidth = NULL,
@@ -580,7 +582,7 @@ S7::method(draw_element, element_polygon) <-
580582
)
581583
}
582584

583-
S7::method(draw_element, element_point) <-
585+
S7::method(element_grob, element_point) <-
584586
function(element, x = 0.5, y = 0.5, colour = NULL,
585587
shape = NULL, fill = NULL, size = NULL,
586588
stroke = NULL, ...,
@@ -594,18 +596,6 @@ S7::method(draw_element, element_point) <-
594596
default.units = default.units, ...)
595597
}
596598

597-
# TODO: the S3 generic should be phased out once S7 is adopted more widely
598-
#' @rdname draw_element
599-
#' @export
600-
element_grob <- function(element, ...) {
601-
UseMethod("element_grob")
602-
}
603-
604-
#' @export
605-
element_grob.default <- function(element, ...) {
606-
draw_element(element, ...)
607-
}
608-
609599
#' Define and register new theme elements
610600
#'
611601
#' The underlying structure of a ggplot2 theme is defined via the element tree, which

man/draw_element.Rd renamed to man/element_grob.Rd

Lines changed: 1 addition & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)