/R/Item-class.R

http://github.com/tengfei/visnab · R · 34 lines · 30 code · 4 blank · 0 comment · 4 complexity · 9d07c9bf51aba3ead836bedc90ce9181 MD5 · raw file

  1. setRefClass("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. setClass("ItemList", representation("VIRTUAL"),
  17. prototype = prototype(elementType = "Item"),
  18. contains = "List")
  19. setClass("SimpleItemList", contains = c("ItemList", "SimpleList"),
  20. prototype = prototype(elementType = "Item"))
  21. ItemList <- function(...)
  22. {
  23. items <- list(...)
  24. if (length(items) == 1 && is.list(items[[1L]]))
  25. items <- items[[1L]]
  26. if (!all(sapply(items, is, "Item")))
  27. stop("all elements in '...' must be Item objects")
  28. ans <- IRanges:::newSimpleList("SimpleItemList", items)
  29. ans
  30. }