/R/GraphicPars-class.R

http://github.com/tengfei/visnab · R · 129 lines · 28 code · 15 blank · 86 comment · 0 complexity · 5a30f9417ea745c435ea1c2efe626ab4 MD5 · raw file

  1. ##-----------------------------------------------------------------##
  2. ## Class GrahpicPars
  3. ##-----------------------------------------------------------------##
  4. ## setOldClass("R::visnab::ControlPanel")
  5. setClass("Parameters", contains = c("VIRTUAL"))
  6. setPars <- function(viewname, pars = list(), prototype = list(), ...,
  7. contains = c("Parameters", "PropertySet"),
  8. where = topenv(parent.frame())){
  9. names <- paste(viewname, "Pars", sep = "")
  10. setPropertySet(names, pars, prototype, ...,
  11. contains = contains)
  12. }
  13. .AllVisnabViews <- c("VisnabView",
  14. "IntervalView",
  15. "TxdbView",
  16. "CoverageView",
  17. "BamView",
  18. "AlignmentView",
  19. "ScaleView",
  20. "SingleChromView",
  21. "SeqView",
  22. "TracksView",
  23. "CircularView")
  24. ## sapply(.AllVisnabViews, function(viewname){
  25. ## gparslst <- list(xlimZoom = "numeric",
  26. ## ylimZoom= "numeric",
  27. ## xlim = "numeric",
  28. ## ylim = "numeric",
  29. ## view = "character",
  30. ## ## fix on active binding of this geom
  31. ## geom = .GeomName(viewname))
  32. ## setPars(viewname, gparslst)
  33. ## })
  34. .GParsName <- function(viewname){
  35. paste(viewname, "Pars", sep = "")
  36. }
  37. ##----------------------------------------------------------------##
  38. ## Constructor for GraphicsPars
  39. ##----------------------------------------------------------------##
  40. ##' GraphicPars is the constructor for generating a set of graphic parameters which
  41. ##' could control specific view
  42. ##'
  43. ##' All the parameters stored in a GraphicPars object are signal objects, which listen
  44. ##' to user's response, when the signal object is changed, it will emit certain binded
  45. ##' function(s), for graphic parameters, it usually just update associated view(s) to
  46. ##' make sure the color or other attributes changes on the fly.
  47. ##'
  48. ##' @title Graphic parameters constructor
  49. ##' @param ... pass paramters to update the default list
  50. ##' @param view specify a default graphic parameters set for particular View Class.
  51. ##' @return a GrahpicPars object, which store all parameteres as fields.
  52. ##' @seealso signalingField
  53. ##' @author Tengfei Yin <yintengfei@gmail.com>
  54. GraphicPars <- function(..., view = "VisnabView", theme = "default"){
  55. ## switch geom
  56. geom <- .Geom(view)
  57. cls <- .GParsName(view)
  58. gp <- new(cls, ..., geom = geom)
  59. ## gp$setTheme(theme)
  60. ## gp$update(...)
  61. return(gp)
  62. }
  63. ## reset = function(themeName){
  64. ## 'reset parameters to default
  65. ## '
  66. ## ## do some thing first
  67. ## callSuper(themeName)
  68. ## },
  69. ## update = function(...){
  70. ## 'reset parameters to default
  71. ## '
  72. ## ## do some thing first
  73. ## callSuper(...)
  74. ## },
  75. ## output = function(){
  76. ## 'output a list of parameters, automatically remove signal
  77. ## function which are just used for internal signal emit.
  78. ## This function return a list, pars shows the names of parameters;
  79. ## value shows value of parameters; listeners shows how many
  80. ## signal function associagted with certain parameter;
  81. ## class shows class of those parameters.
  82. ## '
  83. ## .self$properties()
  84. ## },
  85. ## setTheme = function(themeName){
  86. ## "set parameters based on theme name
  87. ## "
  88. ## .self$reset(themeName)
  89. ## },
  90. ## widget = function(){
  91. ## w <- ControlPanel(.self)
  92. ## ThemeChanged$connect(function(name){
  93. ## vals <-.self$field(name)
  94. ## w$setValue(name, vals)
  95. ## })
  96. ## w
  97. ## }
  98. ## setMethod("show","Parameters",function(object){
  99. ## cat("Parameters stored in pars\n")
  100. ## for(nm in ls(object@.xData)){
  101. ## y <- get(nm,env=object@.xData)
  102. ## if((is(y,"character"))||(is(y,"numeric"))){
  103. ## cat(nm, " = ", toString(y), "\n")
  104. ## }
  105. ## if(is(y,"Signal")){
  106. ## cat(nm, " = ")
  107. ## show(y)
  108. ## }
  109. ## if(is(y,"list")){
  110. ## cat(nm, " = ", "\n")
  111. ## str(y)
  112. ## }
  113. ## }
  114. ## })