25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# A "virtual" class "gDesc" underlies both "grob" and "gPath"
initGrobAutoName <- function() {
  index <- 0
  function(prefix="GRID"suffix="GROB") {
    index <<- index + 1
    paste(prefixsuffixindexsep=".")
  }
}
grobAutoName <- initGrobAutoName()
# Function for user to call to get "autogenerated" grob name
grobName <- function(grob=NULLprefix="GRID") {
    if (is.null(grob))
        grobAutoName(prefix)
    else {
        if (!is.grob(grob))
            stop("Invalid 'grob' argument")
        else
            grobAutoName(prefixclass(grob)[1L])