PageRenderTime 11ms CodeModel.GetById 2ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/R/Item-class.R

http://github.com/tengfei/visnab
R | 34 lines | 30 code | 4 blank | 0 comment | 4 complexity | 9d07c9bf51aba3ead836bedc90ce9181 MD5 | raw file
 1setRefClass("Item", contains = c("AnnotatedWidget", "VIRTUAL"),
 2            fields = list(
 3              checked = "logical"
 4              ),
 5            methods = list(
 6              setChecked = function(bool = TRUE){
 7                checked <<- bool
 8              },
 9              isChecked = function(){
10                checked
11              },
12              initialize = function(...){
13                checked <<- FALSE
14                callSuper(...)
15              }))
16
17setClass("ItemList", representation("VIRTUAL"),
18         prototype = prototype(elementType = "Item"),
19         contains = "List")
20
21setClass("SimpleItemList", contains = c("ItemList", "SimpleList"),
22         prototype = prototype(elementType = "Item"))
23
24ItemList <- function(...)
25{
26  items <- list(...)
27  if (length(items) == 1 && is.list(items[[1L]]))
28    items <- items[[1L]]
29  if (!all(sapply(items, is, "Item")))
30    stop("all elements in '...' must be Item objects")
31  ans <- IRanges:::newSimpleList("SimpleItemList", items)
32  ans
33}
34