Skip to content

Commit 7f12f21

Browse files
committed
Rename nullGrob to zeroGrob
1 parent c6918fe commit 7f12f21

15 files changed

+34
-33
lines changed

NEWS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ ggplot2 0.8.4 (2008-XX-XX)
1515
* stat_qq: now correctly groups results
1616
* facet_wrap: can now specify both ncol and nrow without getting an error
1717
* facet_wrap: now works with statistics that produce both x and y values (e.g. stat_qq)
18-
* geom_boxplot: alpha now affects fill colour of boxes only
18+
* geom_boxplot: alpha now affects fill colour of boxes only
19+
* nullGrob renamed to zeroGrob to avoid name conflict with grid

R/facet-grid-.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ FacetGrid <- proto(Facet, {
180180
col.labels <- add.names(rcolnames(gm))
181181

182182
strip_h <- apply(col.labels, c(2,1), ggstrip, theme = theme)
183-
if (nrow(strip_h) == 1 && ncol(strip_h) == 1) strip_h <- matrix(list(nullGrob()))
183+
if (nrow(strip_h) == 1 && ncol(strip_h) == 1) strip_h <- matrix(list(zeroGrob()))
184184
strip_v <- apply(row.labels, c(1,2), ggstrip, horizontal=FALSE, theme=theme)
185-
if (nrow(strip_v) == 1 && ncol(strip_v) == 1) strip_v <- matrix(list(nullGrob()))
185+
if (nrow(strip_v) == 1 && ncol(strip_v) == 1) strip_v <- matrix(list(zeroGrob()))
186186

187187
list(
188188
h = strip_h,

R/geom-.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Geom <- proto(TopLevel, expr={
2020

2121
draw <- function(...) {}
2222
draw_groups <- function(., data, scales, coordinates, ...) {
23-
if (empty(data)) return(nullGrob())
23+
if (empty(data)) return(zeroGrob())
2424

2525
groups <- split(data, factor(data$group))
2626
grobs <- lapply(groups, function(group) .$draw(group, scales, coordinates, ...))

R/geom-blank.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ GeomBlank <- proto(Geom, {
1414
}
1515

1616
draw_legend <- function(., data, ...) {
17-
nullGrob()
17+
zeroGrob()
1818
}
1919

2020

R/geom-path-.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ GeomPath <- proto(Geom, {
77
# Silently drop lines with less than two points, preserving order
88
rows <- ave(seq_len(nrow(munched)), munched$group, FUN = length)
99
munched <- munched[rows >= 2, ]
10-
if (nrow(munched) < 2) return(nullGrob())
10+
if (nrow(munched) < 2) return(zeroGrob())
1111

1212
# Work out whether we should use lines or segments
1313
attr <- ddply(munched, .(group), function(df) {

R/geom-point-.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ GeomPoint <- proto(Geom, {
33
draw <- function(., data, scales, coordinates, na.rm = FALSE, ...) {
44
data <- remove_missing(data, na.rm,
55
c("x", "y", "size", "shape"), name = "geom_point")
6-
if (empty(data)) return(nullGrob())
6+
if (empty(data)) return(zeroGrob())
77

88
with(coordinates$transform(data, scales),
99
ggname(.$my_name(), pointsGrob(x, y, size=unit(size, "mm"), pch=shape,

R/grob-grid.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ grobGrid <- function(name, nrow, ncol, grobs = NULL, widths = 1, heights = 1, cl
4444

4545
# stopifnot(is.list(grobs))
4646
if (is.null(grobs)) {
47-
grobs <- matrix(list(nullGrob()), nrow = nrow, ncol = ncol)
47+
grobs <- matrix(list(zeroGrob()), nrow = nrow, ncol = ncol)
4848
} else {
49-
mat <- c(grobs, rep(list(nullGrob()), nrow * ncol - length(grobs)))
49+
mat <- c(grobs, rep(list(zeroGrob()), nrow * ncol - length(grobs)))
5050
dim(mat) <- c(ncol, nrow)
5151
grobs <- t(mat)
5252
}

R/grob-null.r

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# Null grob
2-
# The null grob does nothing and has zero size.
1+
# Zero grob
2+
# The zero grob draws nothing and has zero size.
33
#
4-
# @alias widthDetails.nullGrob
5-
# @alias heightDetails.nullGrob
6-
# @alias grobWidth.nullGrob
7-
# @alias grobHeight.nullGrob
8-
# @alias drawDetails.nullGrob
4+
# @alias widthDetails.zeroGrob
5+
# @alias heightDetails.zeroGrob
6+
# @alias grobWidth.zeroGrob
7+
# @alias grobHeight.zeroGrob
8+
# @alias drawDetails.zeroGrob
99
# @keyword internal
10-
nullGrob <- function() .nullGrob
10+
zeroGrob <- function() .zeroGrob
1111

12-
.nullGrob <- grob(cl = "nullGrob", name = "NULL")
13-
widthDetails.nullGrob <-
14-
heightDetails.nullGrob <-
15-
grobWidth.nullGrob <-
16-
grobHeight.nullGrob <- function(x) unit(0, "cm")
12+
.zeroGrob <- grob(cl = "zeroGrob", name = "NULL")
13+
widthDetails.zeroGrob <-
14+
heightDetails.zeroGrob <-
15+
grobWidth.zeroGrob <-
16+
grobHeight.zeroGrob <- function(x) unit(0, "cm")
1717

18-
drawDetails.nullGrob <- function(x, recording) {}
18+
drawDetails.zeroGrob <- function(x, recording) {}
1919

R/guides-legend.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ guide_legends_box <- function(scales, layers, default_mapping, horizontal = FALS
1616
legs <- guide_legends(scales, layers, default_mapping, theme=theme)
1717

1818
n <- length(legs)
19-
if (n == 0) return(nullGrob())
19+
if (n == 0) return(zeroGrob())
2020

2121
if (!horizontal) {
2222
width <- do.call("max", lapply(legs, widthDetails))
@@ -71,7 +71,7 @@ guide_legends <- function(scales, layers, default_mapping, theme) {
7171

7272
build_legend <- function(name, mapping, layers, default_mapping, theme) {
7373
legend_data <- llply(layers, build_legend_data, mapping, default_mapping)
74-
# if (length(legend_data) == 0) return(nullGrob())
74+
# if (length(legend_data) == 0) return(zeroGrob())
7575
# browser()
7676

7777
# Calculate sizes for keys - mainly for v. large points and lines

R/layer.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ Layer <- proto(expr = {
233233
}
234234

235235
make_grob <- function(., data, scales, cs) {
236-
if (empty(data)) return(nullGrob())
236+
if (empty(data)) return(zeroGrob())
237237
data <- .$use_defaults(data)
238238

239239
check_required_aesthetics(.$geom$required_aes, c(names(data), names(.$geom_params)), paste("geom_", .$geom$objname, sep=""))

R/plot-render.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ ggplotGrob <- function(plot, drop = plot$options$drop, keep = plot$options$keep,
6060
legend_box <- if (position != "none") {
6161
guide_legends_box(scales, plot$layers, plot$mapping, horiz, theme)
6262
} else {
63-
nullGrob()
63+
zeroGrob()
6464
}
6565

6666
title <- theme_render(theme, "plot.title", plot$options$title)
@@ -78,7 +78,7 @@ ggplotGrob <- function(plot, drop = plot$options$drop, keep = plot$options$keep,
7878
panels = panels, legend_box = legend_box
7979
)
8080
if (!is.null(keep)) drop <- setdiff(names(grobs), keep)
81-
if (!is.null(drop)) grobs[drop] <- rep(list(nullGrob()), length(drop))
81+
if (!is.null(drop)) grobs[drop] <- rep(list(zeroGrob()), length(drop))
8282

8383
# Calculate sizes ----------------------------------------------------------
8484
if (is.null(legend_box)) position <- "none"

R/theme-elements.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# @keywords dplot
99
theme_blank <- function() {
1010
structure(
11-
function(...) nullGrob(),
11+
function(...) zeroGrob(),
1212
class = "theme",
1313
type = "any",
1414
call = match.call()

R/theme.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ theme_render <- function(theme, element, ..., name = NULL) {
8484
el <- theme[[element]]
8585
if (is.null(el)) {
8686
message("Theme element ", element, " missing")
87-
return(nullGrob())
87+
return(zeroGrob())
8888
}
8989

9090
ggname(ps(element, name, sep = "."), el(...))

R/utilities-grid.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ grobColWidth <- function(mat) {
3838
# Build grob matrix
3939
# Build a matrix of grobs given a vector of grobs and the desired dimensions of the matrix
4040
#
41-
# Any missing cells at the end will be filled in with nullGrobs.
41+
# Any missing cells at the end will be filled in with zeroGrobs.
4242
#
4343
# @arguments vector of grobs
4444
# @arguments number of rows
@@ -50,7 +50,7 @@ grobMatrix <- function(vec, nrow, ncol, as.table = FALSE) {
5050
return(matrix(ncol = ncol, nrow = nrow))
5151
}
5252

53-
mat <- c(vec, rep(list(nullGrob()), nrow * ncol - length(vec)))
53+
mat <- c(vec, rep(list(zeroGrob()), nrow * ncol - length(vec)))
5454
dim(mat) <- c(ncol, nrow)
5555
mat <- t(mat)
5656
if (!as.table) mat <- mat[rev(seq_len(nrow)), ]

R/utilities-layer.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ is.integeric <- function(x) all(floor(x) == x)
1919
# @value data.frame with group variable
2020
# @keyword internal
2121
add_group <- function(data) {
22-
if (empty(data)) return(nullGrob())
22+
if (empty(data)) return(zeroGrob())
2323

2424
if (is.null(data$group)) {
2525
cat <- sapply(data[setdiff(names(data), "label")], plyr::is.discrete)

0 commit comments

Comments
 (0)