R/classes.R
f392cd36
 ## Terminology: I use the term 'report object' equivalent to 'array'.
 ## This is in order to prepare the infrastructure created here also to
b7442596
 ## be useable for reports on other types of objects than arrays (say:
f392cd36
 ## Solexa lanes, microtitre plates, ...). Report objects are identified 
 ## by the numbers 1, 2,... N_r.
8bd55c43
 ##
b7442596
 setClass("svgParameters",
   representation(
8bd55c43
     ## An R function that finds the nodes in the SVG document corresponding to the plot objects.
b7442596
     ## It should hold that length(getPlotObjNodes(doc)) == numPlotObjects            
eb36a8ad
     #getPlotObjNodes = "function",
91e4bb47
     gridObjId = "character",
4238dc3d
     numPlotObjects  = "integer",
f392cd36
     getReportObjIdFromPlotObjId = "function"),   
b7442596
          
   prototype(
eb36a8ad
     #getPlotObjNodes = getMatplotSeries,
91e4bb47
     gridObjId = "xyplot.lines",
4238dc3d
     numPlotObjects  = NA_integer_,             
f392cd36
     getReportObjIdFromPlotObjId = function(x) x),
b7442596
          
4238dc3d
   validity = function(object) {
     if(length(object@numPlotObjects)!=1) return("Invalid slot 'numPlotObjects'.")
b7442596
     return(TRUE)
   }         
 )
6631abd7
 
be4ee726
 ##
 ## Parameters summarising an outlier detection
 ##
 setClass("outlierDetection",
   representation(
     statistic   = "numeric",
     threshold   = "numeric",
     which       = "integer",
7d1ebb43
     description = "character"),   
be4ee726
   prototype(
     statistic   = numeric(0),
     threshold   = NA_real_,
     which       = NA_integer_,
7d1ebb43
     description = NA_character_))
51d8170b
 
8bd55c43
 ##
31580c18
 ## An object of this class contains everything needed to render a report module
 ##
b7442596
 setClass("aqmReportModule",
   representation(
c4d31d30
     plot           = "ANY",
     size           = "numeric",     ## size of the plot in inch
7d1ebb43
     colors         = "character",
c4d31d30
     section        = "character",
     title          = "character",
33d1d092
     id             = "character",
c4d31d30
     legend         = "character",
     outliers       = "outlierDetection",
     defaultdisplay = "character",             
     svg            = "svgParameters"),
8bd55c43
 
b7442596
   prototype(
c4d31d30
     plot           = new("namedList"),
     size           = c(w=NA_real_, h=NA_real_),
7d1ebb43
     colors         = "#b0b0b0",
c4d31d30
     section        = NA_character_,
     title          = NA_character_,
33d1d092
     id             = NA_character_,
c4d31d30
     legend         = NA_character_,
     outliers       = new("outlierDetection"),
     defaultdisplay = "block",      
     svg            = new("svgParameters")),
8bd55c43
 
4238dc3d
   validity = function(object) {
8bd55c43
     for(s in c("section", "title", "legend"))
31580c18
       if (length(slot(object, s)) != 1)
         return(sprintf("Invalid slot '%s'.", s))
     if ((length(object@size)!=2) || !identical(names(object@size), c("w", "h")))
       return("Invalid slot 'size'.")
c4d31d30
     if(!(is.character(object@defaultdisplay) && (length(object@defaultdisplay)==1) && (object@defaultdisplay %in% c("block", "none"))))
       return("Invalid slot 'defaultdisplay'.")
31580c18
     validObject(object@svg, test=TRUE)
8bd55c43
   }
 )