[rkward-cvs] SF.net SVN: rkward:[4334] trunk/rkward/packages/rkwarddev
m-eik at users.sourceforge.net
m-eik at users.sourceforge.net
Sun Sep 30 19:44:35 UTC 2012
Revision: 4334
http://rkward.svn.sourceforge.net/rkward/?rev=4334&view=rev
Author: m-eik
Date: 2012-09-30 19:44:35 +0000 (Sun, 30 Sep 2012)
Log Message:
-----------
rkwarddev: added function rk.plotOptions(). this function returns objects of the corresponding class "rk.plot.opts", which make it very easy to include generic plot options (or similar embedded options, see for instance the color choser in the external MDS plugin)
Modified Paths:
--------------
trunk/rkward/packages/rkwarddev/ChangeLog
trunk/rkward/packages/rkwarddev/DESCRIPTION
trunk/rkward/packages/rkwarddev/NAMESPACE
trunk/rkward/packages/rkwarddev/R/id.R
trunk/rkward/packages/rkwarddev/R/rk-internal.R
trunk/rkward/packages/rkwarddev/R/rk.XML.connect.R
trunk/rkward/packages/rkwarddev/R/rk.XML.embed.R
trunk/rkward/packages/rkwarddev/R/rk.XML.set.R
trunk/rkward/packages/rkwarddev/R/rk.paste.JS.R
trunk/rkward/packages/rkwarddev/R/rk.paste.JS.graph.R
trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R
trunk/rkward/packages/rkwarddev/debian/changelog
trunk/rkward/packages/rkwarddev/inst/CITATION
trunk/rkward/packages/rkwarddev/inst/NEWS.Rd
trunk/rkward/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf
trunk/rkward/packages/rkwarddev/man/rk.paste.JS.graph.Rd
trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd
Added Paths:
-----------
trunk/rkward/packages/rkwarddev/R/rk.plot.opts-class.R
trunk/rkward/packages/rkwarddev/R/rk.plotOptions.R
trunk/rkward/packages/rkwarddev/man/rk.plotOptions.Rd
Modified: trunk/rkward/packages/rkwarddev/ChangeLog
===================================================================
--- trunk/rkward/packages/rkwarddev/ChangeLog 2012-09-30 13:54:17 UTC (rev 4333)
+++ trunk/rkward/packages/rkwarddev/ChangeLog 2012-09-30 19:44:35 UTC (rev 4334)
@@ -1,5 +1,13 @@
ChangeLog for package rkwarddev
+changes in version 0.05-8 (2012-09-30)
+added:
+ - new function rk.plotOptions() and class "rk.plot.opts" to simplify code generation for plots;
+ this also caused changes in the internal workflow, especially for child.node() and rk.paste.JS()
+changed:
+ - rk.paste.JS.graph() also takes objects of class "rk.plot.opts"
+ - rk.XML.embed() now supresses the label if "button=FALSE"
+
changes in version 0.05-7 (2012-09-29)
added:
- new function rk.paste.JS.graph() to simplify JS code generation for plots
Modified: trunk/rkward/packages/rkwarddev/DESCRIPTION
===================================================================
--- trunk/rkward/packages/rkwarddev/DESCRIPTION 2012-09-30 13:54:17 UTC (rev 4333)
+++ trunk/rkward/packages/rkwarddev/DESCRIPTION 2012-09-30 19:44:35 UTC (rev 4334)
@@ -14,8 +14,8 @@
URL: http://rkward.sourceforge.net
Authors at R: c(person(given="Meik", family="Michalke",
email="meik.michalke at hhu.de", role=c("aut", "cre")))
-Version: 0.05-7
-Date: 2012-09-29
+Version: 0.05-8
+Date: 2012-09-30
Collate:
'echo.R'
'id.R'
@@ -36,6 +36,9 @@
'rk.JS.vars.R'
'rk.paste.JS.graph.R'
'rk.paste.JS.R'
+ 'rk.plotOptions.R'
+ 'rk.XML.embed.R'
+ 'rk.plot.opts-class.R'
'rk.rkh.doc.R'
'rk.XML.plugin.R'
'rk.plug.comp-class.R'
@@ -69,7 +72,6 @@
'rk.XML.copy.R'
'rk.XML.dialog.R'
'rk.XML.dropdown.R'
- 'rk.XML.embed.R'
'rk.XML.entry.R'
'rk.XML.external.R'
'rk.XML.formula.R'
Modified: trunk/rkward/packages/rkwarddev/NAMESPACE
===================================================================
--- trunk/rkward/packages/rkwarddev/NAMESPACE 2012-09-30 13:54:17 UTC (rev 4333)
+++ trunk/rkward/packages/rkwarddev/NAMESPACE 2012-09-30 19:44:35 UTC (rev 4334)
@@ -2,6 +2,7 @@
exportClasses(rk.JS.ite)
exportClasses(rk.JS.opt)
exportClasses(rk.JS.var)
+exportClasses(rk.plot.opts)
exportClasses(rk.plug.comp)
export(echo)
export(id)
@@ -18,6 +19,7 @@
export(rk.JS.vars)
export(rk.paste.JS)
export(rk.paste.JS.graph)
+export(rk.plotOptions)
export(rk.plugin.component)
export(rk.plugin.skeleton)
export(rk.rkh.caption)
Modified: trunk/rkward/packages/rkwarddev/R/id.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/id.R 2012-09-30 13:54:17 UTC (rev 4333)
+++ trunk/rkward/packages/rkwarddev/R/id.R 2012-09-30 19:44:35 UTC (rev 4334)
@@ -29,6 +29,10 @@
id <- function(..., quote=FALSE, collapse="", js=TRUE){
full.content <- list(...)
ID.content <- sapply(full.content, function(this.part){
+ # if this is a plot options object, by default only paste the printout slot
+ # and discard the rest
+ this.part <- stripCont(this.part, get="printout")
+
if(inherits(this.part, "XiMpLe.node")){
node.id <- this.part at attributes$id
if(isTRUE(js)){
Modified: trunk/rkward/packages/rkwarddev/R/rk-internal.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk-internal.R 2012-09-30 13:54:17 UTC (rev 4333)
+++ trunk/rkward/packages/rkwarddev/R/rk-internal.R 2012-09-30 19:44:35 UTC (rev 4334)
@@ -17,9 +17,31 @@
} ## end function auto.ids()
+## function stripCont()
+# get slots out of certain container objects
+stripCont <- function(obj, get="printout"){
+ if(inherits(obj, "rk.plot.opts")){
+ # if this is a plot options object, extract the XML slot
+ # and discard the rest
+ obj <- slot(obj, get)
+ } else {}
+ return(obj)
+}
+## end function stripCont()
+
+
+## function stripXML()
+# get XML node out of container objects
+stripXML <- function(obj){
+ return(stripCont(obj, get="XML"))
+}
+## end function stripXML()
+
+
## function child.list()
# convenience function to let single children be provided without list()
-# 'empty' van be used to make sure a tag is non-empty without actual value
+# 'empty' can be used to make sure a tag is non-empty without actual value
+# this function also reduces rk.plot.opts objects to their XiMpLe.node slot
child.list <- function(children, empty=TRUE){
if(inherits(children, "XiMpLe.node")){
children <- list(children)
@@ -32,6 +54,9 @@
} else if(identical(children, list()) & !isTRUE(empty)){
children <- list("")
} else {}
+ children <- lapply(children, function(this.child){
+ stripXML(this.child)
+ })
}
return(children)
} ## end function child.list()
@@ -543,6 +568,10 @@
if(is.null(node.names)){
# check the node names and allow only valid ones
node.names <- sapply(child.list(children), function(this.child){
+ # if this is a plot options object, by default extract the XML slot
+ # and discard the rest
+ this.child <- stripXML(this.child)
+
if(inherits(this.child, "XiMpLe.node")){
return(slot(this.child, "name"))
} else {
Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.connect.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.connect.R 2012-09-30 13:54:17 UTC (rev 4333)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.connect.R 2012-09-30 19:44:35 UTC (rev 4334)
@@ -31,6 +31,10 @@
rk.XML.connect <- function(governor, client, get="state", set="enabled", not=FALSE, reconcile=FALSE){
+ # check for container objects
+ governor <- stripXML(governor)
+ client <- stripXML(client)
+
if(length(governor) > 1 | length(client) > 1){
stop(simpleError("'governor' and 'client' must be of length 1!"))
} else {}
Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.embed.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.embed.R 2012-09-30 13:54:17 UTC (rev 4333)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.embed.R 2012-09-30 19:44:35 UTC (rev 4334)
@@ -19,7 +19,7 @@
attr.list[["as_button"]] <- "true"
} else {}
- if(!identical(label, "Options")){
+ if(!identical(label, "Options") && isTRUE(button)){
attr.list[["label"]] <- label
} else {}
Modified: trunk/rkward/packages/rkwarddev/R/rk.XML.set.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.XML.set.R 2012-09-30 13:54:17 UTC (rev 4333)
+++ trunk/rkward/packages/rkwarddev/R/rk.XML.set.R 2012-09-30 19:44:35 UTC (rev 4334)
@@ -24,6 +24,9 @@
stop(simpleError("'id' and 'to' must be of length 1!"))
} else {}
+ # check for container objects
+ id <- stripXML(id)
+
# let's see if we need to extract IDs first
prop.id <- check.ID(id)
Modified: trunk/rkward/packages/rkwarddev/R/rk.paste.JS.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.paste.JS.R 2012-09-30 13:54:17 UTC (rev 4333)
+++ trunk/rkward/packages/rkwarddev/R/rk.paste.JS.R 2012-09-30 19:44:35 UTC (rev 4334)
@@ -40,6 +40,10 @@
all.objects <- list(...)
paste.results <- paste(sapply(all.objects, function(this.object){
+ # if this is a plot options object, by default only paste the printout slot
+ # and discard the rest
+ this.object <- stripCont(this.object, get="printout")
+
if(inherits(this.object, "rk.JS.ite")){
# done by an internal function, to ease handling of recursions
result <- paste.JS.ite(this.object, level=level, indent.by=indent.by, empty.e=empty.e)
Modified: trunk/rkward/packages/rkwarddev/R/rk.paste.JS.graph.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.paste.JS.graph.R 2012-09-30 13:54:17 UTC (rev 4333)
+++ trunk/rkward/packages/rkwarddev/R/rk.paste.JS.graph.R 2012-09-30 19:44:35 UTC (rev 4334)
@@ -10,9 +10,10 @@
#' \code{...}.
#'
#' @param ... The actual plot code, passed through to \code{rk.paste.JS}.
-#' @param plotOpts A node object generated by \code{rk.XML.embed}, i.e. embedded plot options.
+#' @param plotOpts An object generated by \code{rk.XML.embed} or \code{rk.plotOptions}, i.e. embedded plot options.
#' @param printoutObj An \code{rk.JS.var} object fetching the \code{"code.printout"} modifier of \code{plotOpts}
-#' (see examples below!).
+#' (see examples below!). If \code{NULL} and \code{plotOpts} is of class \code{rk.plot.opts} (as returned by \code{rk.plotOptions}),
+#' will be fetched from \code{plotOpts} automatically.
#' @return A character string.
#' @export
#' @seealso
@@ -21,19 +22,15 @@
#' tmp.var.selectVars <- rk.XML.varselector(label="Select data")
#' tmp.var.x <- rk.XML.varslot(label="My data", source=tmp.var.selectVars, required=TRUE)
#' # let this be the embedded generic plot options in yout plot dialog
-#' tmp.plot.options <- rk.XML.embed(component="rkward::plot_options", button=TRUE, label="Generic plot options")
+#' tmp.plot.options <- rk.plotOptions()
#'
-#' # now generate an rk.JS.var object to import the "printout" code from the embedded options
-#' js.po.printout <- rk.JS.vars(tmp.plot.options, modifiers="code.printout", check.modifiers=FALSE)
-#'
#' # you can now generate the plot code using generic plot options
#' js.prnt <- rk.paste.JS.graph(
#' echo("\t\tplot("),
#' echo("\n\t\t\tx=", tmp.var.x),
-#' echo(js.po.printout),
+#' echo(tmp.plot.options),
#' echo(")"),
-#' plotOpts=tmp.plot.options,
-#' printoutObj=js.po.printout)
+#' plotOpts=tmp.plot.options)
#'
#' cat(js.prnt)
rk.paste.JS.graph <- function(..., plotOpts=NULL, printoutObj=NULL, level=2, indent.by="\t", empty.e=FALSE){
@@ -43,15 +40,25 @@
# define variables
js.prnt <- rk.paste.JS(
if(!is.null(plotOpts)){
+ if(inherits(plotOpts, "rk.plot.opts")){
+ js.po.preprocess <- slot(plotOpts, "preprocess")
+ js.po.calculate <- slot(plotOpts, "calculate")
+ if(is.null(printoutObj)){
+ printoutObj <- slot(plotOpts, "printout")
+ } else {}
+ } else {
+ js.po.preprocess <- rk.JS.vars(plotOpts, modifiers="code.preprocess", check.modifiers=FALSE)
+ js.po.calculate <- rk.JS.vars(plotOpts, modifiers="code.calculate", check.modifiers=FALSE)
+ }
rk.paste.JS(
rk.comment("in case there are generic plot options defined:"),
- js.po.preprocess <- rk.JS.vars(plotOpts, modifiers="code.preprocess", check.modifiers=FALSE),
+ js.po.preprocess,
if(!is.null(printoutObj)){
printoutObj
} else {
warning("rk.paste.JS.graph: you're using plot options, but 'printoutObj' is empty, is that intended?")
},
- js.po.calculate <- rk.JS.vars(plotOpts, modifiers="code.calculate", check.modifiers=FALSE)
+ js.po.calculate
)
} else {},
level=level, indent.by=indent.by, empty.e=empty.e
Added: trunk/rkward/packages/rkwarddev/R/rk.plot.opts-class.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.plot.opts-class.R (rev 0)
+++ trunk/rkward/packages/rkwarddev/R/rk.plot.opts-class.R 2012-09-30 19:44:35 UTC (rev 4334)
@@ -0,0 +1,33 @@
+#' @export
+
+# this simple class is for XML and JavaScript generation,
+# produced by rk.plotOptions()
+
+#' @include rk.JS.var-class.R
+#' @include rk.JS.vars.R
+#' @include rk.XML.embed.R
+
+setClass("rk.plot.opts",
+ representation=representation(
+ XML="XiMpLe.node",
+ preprocess="rk.JS.var",
+ printout="rk.JS.var",
+ calculate="rk.JS.var"
+ ),
+ prototype(
+ XML=rk.XML.embed(component="rkward::plot_options", button=TRUE, label="Generic plot options", id.name="auto"),
+ preprocess=rk.JS.vars(
+ rk.XML.embed(component="rkward::plot_options", button=TRUE, label="Generic plot options", id.name="auto"),
+ modifiers="code.preprocess", check.modifiers=FALSE),
+ printout=rk.JS.vars(
+ rk.XML.embed(component="rkward::plot_options", button=TRUE, label="Generic plot options", id.name="auto"),
+ modifiers="code.printout", check.modifiers=FALSE),
+ calculate=rk.JS.vars(
+ rk.XML.embed(component="rkward::plot_options", button=TRUE, label="Generic plot options", id.name="auto"),
+ modifiers="code.calculate", check.modifiers=FALSE)
+ )
+)
+
+# setValidity("rk.plot.opts", function(object){
+# return(TRUE)
+# })
Added: trunk/rkward/packages/rkwarddev/R/rk.plotOptions.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.plotOptions.R (rev 0)
+++ trunk/rkward/packages/rkwarddev/R/rk.plotOptions.R 2012-09-30 19:44:35 UTC (rev 4334)
@@ -0,0 +1,58 @@
+#' Create an object for plot options in RKWard plugins
+#'
+#' Generates XML and JavaScript code snippets by calling \code{rk.XML.embed} and \code{rk.JS.vars} with useful presets. The
+#' resulting object can be used inside the dialog XML object (to place the plot options button and disable certain tabs), as
+#' well as in the JS object (to then insert the actual plot options).
+#'
+#' @param label A character string, text label for the button (only used if \code{button=TRUE}).
+#' @param embed A character string, registered name (\code{id} in pluginmap file) of the plot options component to be embedded.
+#' @param button Logical, whether the plot options should be embedded as a button and appear if it's pressed.
+#' @param id.name Character string, a unique ID for this plugin element.
+#' If \code{"auto"}, an ID will be generated automatically from the label and component strings.
+#' @return An object of class \code{rk.plot.opts}.
+#' @export
+#' @seealso \href{help:rkwardplugins}{Introduction to Writing Plugins for RKWard}
+#' @examples
+#' test.plotOptions <- rk.plotOptions()
+#'
+#' # see how differently this object class is treated
+#' # e.g., in the XML context
+#' rk.XML.dialog(test.plotOptions)
+#' # use this in the logic section to disable the "type" slot
+#' rk.XML.set(test.plotOptions, set="allow_type", to=FALSE)
+#'
+#' # now in JS context
+#' # manually define the variable
+#' cat(rk.paste.JS(test.plotOptions))
+#' # this is usually not necessary, as rk.paste.JS.graph() can
+#' # define variables automatically
+#' cat(
+#' rk.paste.JS.graph(
+#' echo("plot(", test.plotOptions, ")"),
+#' plotOpts=test.plotOptions
+#' )
+#' )
+#'
+#' # as you can also see in the above example, echo() just
+#' # fills in the JS varaible
+#' echo(test.plotOptions)
+
+rk.plotOptions <- function(label="Generic plot options", embed="rkward::plot_options", button=TRUE, id.name="auto"){
+
+ if(identical(id.name, "auto")){
+ id.name <- auto.ids(paste(embed, label, sep=""), prefix=ID.prefix("embed"), chars=12)
+ } else {}
+
+ genPlotOpts.XML <- rk.XML.embed(component=embed, button=button, label=label, id.name=id.name)
+ genPlotOpts.JS.preprocess <- rk.JS.vars(genPlotOpts.XML, modifiers="code.preprocess", check.modifiers=FALSE)
+ genPlotOpts.JS.printout <- rk.JS.vars(genPlotOpts.XML, modifiers="code.printout", check.modifiers=FALSE)
+ genPlotOpts.JS.calculate <- rk.JS.vars(genPlotOpts.XML, modifiers="code.calculate", check.modifiers=FALSE)
+
+ genPlotOpts.all <- new("rk.plot.opts",
+ XML=genPlotOpts.XML,
+ preprocess=genPlotOpts.JS.preprocess,
+ printout=genPlotOpts.JS.printout,
+ calculate=genPlotOpts.JS.calculate)
+
+ return(genPlotOpts.all)
+}
Modified: trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R 2012-09-30 13:54:17 UTC (rev 4333)
+++ trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R 2012-09-30 19:44:35 UTC (rev 4334)
@@ -3,8 +3,8 @@
#' \tabular{ll}{
#' Package: \tab rkwarddev\cr
#' Type: \tab Package\cr
-#' Version: \tab 0.05-7\cr
-#' Date: \tab 2012-09-29\cr
+#' Version: \tab 0.05-8\cr
+#' Date: \tab 2012-09-30\cr
#' Depends: \tab R (>= 2.9.0),methods,XiMpLe (>= 0.03-12),rkward (>= 0.5.6)\cr
#' Enhances: \tab rkward\cr
#' Encoding: \tab UTF-8\cr
Modified: trunk/rkward/packages/rkwarddev/debian/changelog
===================================================================
--- trunk/rkward/packages/rkwarddev/debian/changelog 2012-09-30 13:54:17 UTC (rev 4333)
+++ trunk/rkward/packages/rkwarddev/debian/changelog 2012-09-30 19:44:35 UTC (rev 4334)
@@ -1,3 +1,9 @@
+r-other-rkward-rkwarddev (0.05-8-1) unstable; urgency=low
+
+ * new upstream release
+
+ -- m.eik michalke <meik.michalke at hhu.de> Sun, 30 Sep 2012 19:56:48 +0000
+
r-other-rkward-rkwarddev (0.05-7-1) unstable; urgency=low
* new upstream release
Modified: trunk/rkward/packages/rkwarddev/inst/CITATION
===================================================================
--- trunk/rkward/packages/rkwarddev/inst/CITATION 2012-09-30 13:54:17 UTC (rev 4333)
+++ trunk/rkward/packages/rkwarddev/inst/CITATION 2012-09-30 19:44:35 UTC (rev 4334)
@@ -2,12 +2,12 @@
title="rkwarddev: A collection of tools for RKWard plugin development",
author="Meik Michalke",
year="2012",
- note="(Version 0.05-7)",
+ note="(Version 0.05-8)",
url="http://rkward.sourceforge.net",
textVersion =
paste("Michalke, M. (2012). ",
- "rkwarddev: A collection of tools for RKWard plugin development (Version 0.05-7). ",
+ "rkwarddev: A collection of tools for RKWard plugin development (Version 0.05-8). ",
"Available from http://rkward.sourceforge.net",
sep=""),
Modified: trunk/rkward/packages/rkwarddev/inst/NEWS.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/inst/NEWS.Rd 2012-09-30 13:54:17 UTC (rev 4333)
+++ trunk/rkward/packages/rkwarddev/inst/NEWS.Rd 2012-09-30 19:44:35 UTC (rev 4334)
@@ -1,6 +1,20 @@
\name{NEWS}
\title{News for Package 'rkwarddev'}
\encoding{UTF-8}
+\section{Changes in rkwarddev version 0.05-8 (2012-09-30)}{
+ \subsection{added}{
+ \itemize{
+ \item new function \code{rk.plotOptions()} and class \code{"rk.plot.opts"} to simplify code generation for plots;
+ this also caused changes in the internal workflow, especially for \code{child.node()} and \code{rk.paste.JS()}
+ }
+ }
+ \subsection{changed}{
+ \itemize{
+ \item \code{rk.paste.JS.graph()} also takes objects of class \code{"rk.plot.opts"}
+ \item \code{rk.XML.embed()} now supresses the label if "button=FALSE"
+ }
+ }
+}
\section{Changes in rkwarddev version 0.05-7 (2012-09-29)}{
\subsection{added}{
\itemize{
Modified: trunk/rkward/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf
===================================================================
(Binary files differ)
Modified: trunk/rkward/packages/rkwarddev/man/rk.paste.JS.graph.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.paste.JS.graph.Rd 2012-09-30 13:54:17 UTC (rev 4333)
+++ trunk/rkward/packages/rkwarddev/man/rk.paste.JS.graph.Rd 2012-09-30 19:44:35 UTC (rev 4334)
@@ -10,12 +10,16 @@
\item{...}{The actual plot code, passed through to
\code{rk.paste.JS}.}
- \item{plotOpts}{A node object generated by
- \code{rk.XML.embed}, i.e. embedded plot options.}
+ \item{plotOpts}{An object generated by
+ \code{rk.XML.embed} or \code{rk.plotOptions}, i.e.
+ embedded plot options.}
\item{printoutObj}{An \code{rk.JS.var} object fetching
the \code{"code.printout"} modifier of \code{plotOpts}
- (see examples below!).}
+ (see examples below!). If \code{NULL} and \code{plotOpts}
+ is of class \code{rk.plot.opts} (as returned by
+ \code{rk.plotOptions}), will be fetched from
+ \code{plotOpts} automatically.}
}
\value{
A character string.
@@ -39,19 +43,15 @@
tmp.var.selectVars <- rk.XML.varselector(label="Select data")
tmp.var.x <- rk.XML.varslot(label="My data", source=tmp.var.selectVars, required=TRUE)
# let this be the embedded generic plot options in yout plot dialog
-tmp.plot.options <- rk.XML.embed(component="rkward::plot_options", button=TRUE, label="Generic plot options")
+tmp.plot.options <- rk.plotOptions()
-# now generate an rk.JS.var object to import the "printout" code from the embedded options
-js.po.printout <- rk.JS.vars(tmp.plot.options, modifiers="code.printout", check.modifiers=FALSE)
-
# you can now generate the plot code using generic plot options
js.prnt <- rk.paste.JS.graph(
echo("\\t\\tplot("),
echo("\\n\\t\\t\\tx=", tmp.var.x),
- echo(js.po.printout),
+ echo(tmp.plot.options),
echo(")"),
- plotOpts=tmp.plot.options,
- printoutObj=js.po.printout)
+ plotOpts=tmp.plot.options)
cat(js.prnt)
}
Added: trunk/rkward/packages/rkwarddev/man/rk.plotOptions.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.plotOptions.Rd (rev 0)
+++ trunk/rkward/packages/rkwarddev/man/rk.plotOptions.Rd 2012-09-30 19:44:35 UTC (rev 4334)
@@ -0,0 +1,65 @@
+\name{rk.plotOptions}
+\alias{rk.plotOptions}
+\title{Create an object for plot options in RKWard plugins}
+\usage{
+ rk.plotOptions(label = "Generic plot options",
+ embed = "rkward::plot_options", button = TRUE,
+ id.name = "auto")
+}
+\arguments{
+ \item{label}{A character string, text label for the
+ button (only used if \code{button=TRUE}).}
+
+ \item{embed}{A character string, registered name
+ (\code{id} in pluginmap file) of the plot options
+ component to be embedded.}
+
+ \item{button}{Logical, whether the plot options should be
+ embedded as a button and appear if it's pressed.}
+
+ \item{id.name}{Character string, a unique ID for this
+ plugin element. If \code{"auto"}, an ID will be
+ generated automatically from the label and component
+ strings.}
+}
+\value{
+ An object of class \code{rk.plot.opts}.
+}
+\description{
+ Generates XML and JavaScript code snippets by calling
+ \code{rk.XML.embed} and \code{rk.JS.vars} with useful
+ presets. The resulting object can be used inside the
+ dialog XML object (to place the plot options button and
+ disable certain tabs), as well as in the JS object (to
+ then insert the actual plot options).
+}
+\examples{
+test.plotOptions <- rk.plotOptions()
+
+# see how differently this object class is treated
+# e.g., in the XML context
+rk.XML.dialog(test.plotOptions)
+# use this in the logic section to disable the "type" slot
+rk.XML.set(test.plotOptions, set="allow_type", to=FALSE)
+
+# now in JS context
+# manually define the variable
+cat(rk.paste.JS(test.plotOptions))
+# this is usually not necessary, as rk.paste.JS.graph() can
+# define variables automatically
+cat(
+ rk.paste.JS.graph(
+ echo("plot(", test.plotOptions, ")"),
+ plotOpts=test.plotOptions
+ )
+)
+
+# as you can also see in the above example, echo() just
+# fills in the JS varaible
+echo(test.plotOptions)
+}
+\seealso{
+ \href{help:rkwardplugins}{Introduction to Writing Plugins
+ for RKWard}
+}
+
Modified: trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd 2012-09-30 13:54:17 UTC (rev 4333)
+++ trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd 2012-09-30 19:44:35 UTC (rev 4334)
@@ -8,8 +8,8 @@
}
\details{
\tabular{ll}{ Package: \tab rkwarddev\cr Type: \tab
- Package\cr Version: \tab 0.05-7\cr Date: \tab
- 2012-09-29\cr Depends: \tab R (>= 2.9.0),methods,XiMpLe
+ Package\cr Version: \tab 0.05-8\cr Date: \tab
+ 2012-09-30\cr Depends: \tab R (>= 2.9.0),methods,XiMpLe
(>= 0.03-12),rkward (>= 0.5.6)\cr Enhances: \tab
rkward\cr Encoding: \tab UTF-8\cr License: \tab GPL (>=
3)\cr LazyLoad: \tab yes\cr URL: \tab
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list