[rkward-cvs] SF.net SVN: rkward:[4330] trunk/rkward/packages/rkwarddev
m-eik at users.sourceforge.net
m-eik at users.sourceforge.net
Sat Sep 29 21:36:41 UTC 2012
Revision: 4330
http://rkward.svn.sourceforge.net/rkward/?rev=4330&view=rev
Author: m-eik
Date: 2012-09-29 21:36:41 +0000 (Sat, 29 Sep 2012)
Log Message:
-----------
rkwarddev: added new function rk.paste.JS.graph(), which returns all code between graph.on() and graph.off(), inside try(), and takes some care of generic plot options.
Modified Paths:
--------------
trunk/rkward/packages/rkwarddev/ChangeLog
trunk/rkward/packages/rkwarddev/DESCRIPTION
trunk/rkward/packages/rkwarddev/NAMESPACE
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/rkwarddev-package.Rd
Added Paths:
-----------
trunk/rkward/packages/rkwarddev/R/rk.paste.JS.graph.R
trunk/rkward/packages/rkwarddev/man/rk.paste.JS.graph.Rd
Modified: trunk/rkward/packages/rkwarddev/ChangeLog
===================================================================
--- trunk/rkward/packages/rkwarddev/ChangeLog 2012-09-29 15:13:30 UTC (rev 4329)
+++ trunk/rkward/packages/rkwarddev/ChangeLog 2012-09-29 21:36:41 UTC (rev 4330)
@@ -1,5 +1,9 @@
ChangeLog for package rkwarddev
+changes in version 0.05-7 (2012-09-29)
+added:
+ - new function rk.paste.JS.graph() to simplify JS code generation for plots
+
changes in version 0.05-6 (2012-05-10)
added:
- rk.XML.wizard() and rk.XML.dialog() can now set the "recommended" attribute
Modified: trunk/rkward/packages/rkwarddev/DESCRIPTION
===================================================================
--- trunk/rkward/packages/rkwarddev/DESCRIPTION 2012-09-29 15:13:30 UTC (rev 4329)
+++ trunk/rkward/packages/rkwarddev/DESCRIPTION 2012-09-29 21:36:41 UTC (rev 4330)
@@ -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-6
-Date: 2012-05-10
+Version: 0.05-7
+Date: 2012-09-29
Collate:
'echo.R'
'id.R'
@@ -34,6 +34,7 @@
'rk.JS.scan.R'
'rk.JS.var-class.R'
'rk.JS.vars.R'
+ 'rk.paste.JS.graph.R'
'rk.paste.JS.R'
'rk.rkh.doc.R'
'rk.XML.plugin.R'
Modified: trunk/rkward/packages/rkwarddev/NAMESPACE
===================================================================
--- trunk/rkward/packages/rkwarddev/NAMESPACE 2012-09-29 15:13:30 UTC (rev 4329)
+++ trunk/rkward/packages/rkwarddev/NAMESPACE 2012-09-29 21:36:41 UTC (rev 4330)
@@ -17,6 +17,7 @@
export(rk.JS.scan)
export(rk.JS.vars)
export(rk.paste.JS)
+export(rk.paste.JS.graph)
export(rk.plugin.component)
export(rk.plugin.skeleton)
export(rk.rkh.caption)
Added: trunk/rkward/packages/rkwarddev/R/rk.paste.JS.graph.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rk.paste.JS.graph.R (rev 0)
+++ trunk/rkward/packages/rkwarddev/R/rk.paste.JS.graph.R 2012-09-29 21:36:41 UTC (rev 4330)
@@ -0,0 +1,104 @@
+#' Paste simple JavaScript plot code
+#'
+#' This function is similar to \code{rk.paste.JS}, but adds some code parts to its output which
+#' are commonly used to generate plots with RKWard.
+#'
+#' The contents of the \code{...} argument are evaluated by \code{rk.paste.JS} and encapsulated
+#' between \code{if(full)\{rk.graph.on()\} try(\{} and \code{\}) if(full)\{rk.graph.off()\}}. If generic
+#' plot options are supplied, their \code{"code.preprocess"} and \code{"code.calculate"} modifiers are
+#' also automatically taken care of, so you only need to include \code{"code.printout"} inside of
+#' \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 printoutObj An \code{rk.JS.var} object fetching the \code{"code.printout"} modifier of \code{plotOpts}
+#' (see examples below!).
+#' @return A character string.
+#' @export
+#' @seealso
+#' \code{\link[rkwarddev:rk.paste.JS]{rk.paste.JS}}
+#' @examples
+#' 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")
+#'
+#' # 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(")"),
+#' plotOpts=tmp.plot.options,
+#' printoutObj=js.po.printout)
+#'
+#' cat(js.prnt)
+rk.paste.JS.graph <- function(..., plotOpts=NULL, printoutObj=NULL, level=2, indent.by="\t", empty.e=FALSE){
+
+ plotOptsIndent <- paste(rep("\\t", level), collapse="")
+
+ # define variables
+ js.prnt <- rk.paste.JS(
+ if(!is.null(plotOpts)){
+ 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),
+ 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)
+ )
+ } else {},
+ level=level, indent.by=indent.by, empty.e=empty.e
+ )
+
+ # graph.on() & begin try()
+ js.prnt <- paste(js.prnt, rk.paste.JS(
+ ite("full", echo("rk.graph.on()\n")),
+ echo("\ttry({\n"),
+ level=level, indent.by=indent.by, empty.e=empty.e
+ ), sep="\n\n")
+
+ # plot options: preprocess
+ js.prnt <- paste(js.prnt, rk.paste.JS(
+ if(!is.null(plotOpts)){
+ rk.paste.JS(
+ rk.comment("insert any option-setting code that should be run before the actual plotting commands:"),
+ id("\t\tprintIndentedUnlessEmpty(\"", plotOptsIndent, "\", ", js.po.preprocess, ", \"\\n\", \"\");")
+ )
+ } else {},
+ level=level, indent.by=indent.by, empty.e=empty.e
+ ), sep="\n\n")
+
+ # here comes the plot
+ js.prnt <- paste(js.prnt, rk.paste.JS(
+ rk.comment("the actual plot:"),
+ rk.paste.JS(..., level=level, indent.by=indent.by, empty.e=empty.e),
+ level=level, indent.by=indent.by, empty.e=empty.e
+ ), sep="\n\n")
+
+ # plot options: postprocess
+ js.prnt <- paste(js.prnt, rk.paste.JS(
+ if(!is.null(plotOpts)){
+ rk.paste.JS(
+ rk.comment("insert any option-setting code that should be run after the actual plot:"),
+ id("\t\tprintIndentedUnlessEmpty(\"", plotOptsIndent, "\", ", js.po.calculate, ", \"\\n\", \"\");")
+ )
+ } else {},
+ level=level, indent.by=indent.by, empty.e=empty.e
+ ), sep="\n\n")
+
+ # end try() & graph.off()
+ js.prnt <- paste(js.prnt, rk.paste.JS(
+ echo("\n\t})\n"),
+ ite("full", echo("rk.graph.off()\n")),
+ level=level, indent.by=indent.by, empty.e=empty.e
+ ), sep="\n\n")
+
+ return(js.prnt)
+}
Modified: trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R 2012-09-29 15:13:30 UTC (rev 4329)
+++ trunk/rkward/packages/rkwarddev/R/rkwarddev-package.R 2012-09-29 21:36:41 UTC (rev 4330)
@@ -3,8 +3,8 @@
#' \tabular{ll}{
#' Package: \tab rkwarddev\cr
#' Type: \tab Package\cr
-#' Version: \tab 0.05-6\cr
-#' Date: \tab 2012-05-10\cr
+#' Version: \tab 0.05-7\cr
+#' Date: \tab 2012-09-29\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
@@ -19,6 +19,6 @@
#' @name rkwarddev-package
#' @docType package
#' @title A collection of tools for RKWard plugin development.
-#' @author m.eik michalke \email{meik.michalke@@hhu.de}
+#' @author Meik Michalke \email{meik.michalke@@hhu.de}
#' @keywords package
NULL
Modified: trunk/rkward/packages/rkwarddev/debian/changelog
===================================================================
--- trunk/rkward/packages/rkwarddev/debian/changelog 2012-09-29 15:13:30 UTC (rev 4329)
+++ trunk/rkward/packages/rkwarddev/debian/changelog 2012-09-29 21:36:41 UTC (rev 4330)
@@ -1,3 +1,9 @@
+r-other-rkward-rkwarddev (0.05-7-1) unstable; urgency=low
+
+ * new upstream release
+
+ -- m.eik michalke <meik.michalke at hhu.de> Sat, 29 Sep 2012 19:13:55 +0000
+
r-other-rkward-rkwarddev (0.05-6-1) unstable; urgency=low
* new upstream release
Modified: trunk/rkward/packages/rkwarddev/inst/CITATION
===================================================================
--- trunk/rkward/packages/rkwarddev/inst/CITATION 2012-09-29 15:13:30 UTC (rev 4329)
+++ trunk/rkward/packages/rkwarddev/inst/CITATION 2012-09-29 21:36:41 UTC (rev 4330)
@@ -2,12 +2,12 @@
title="rkwarddev: A collection of tools for RKWard plugin development",
author="Meik Michalke",
year="2012",
- note="(Version 0.05-6)",
+ note="(Version 0.05-7)",
url="http://rkward.sourceforge.net",
textVersion =
paste("Michalke, M. (2012). ",
- "rkwarddev: A collection of tools for RKWard plugin development (Version 0.05-6). ",
+ "rkwarddev: A collection of tools for RKWard plugin development (Version 0.05-7). ",
"Available from http://rkward.sourceforge.net",
sep=""),
Modified: trunk/rkward/packages/rkwarddev/inst/NEWS.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/inst/NEWS.Rd 2012-09-29 15:13:30 UTC (rev 4329)
+++ trunk/rkward/packages/rkwarddev/inst/NEWS.Rd 2012-09-29 21:36:41 UTC (rev 4330)
@@ -1,6 +1,13 @@
\name{NEWS}
\title{News for Package 'rkwarddev'}
\encoding{UTF-8}
+\section{Changes in rkwarddev version 0.05-7 (2012-09-29)}{
+ \subsection{added}{
+ \itemize{
+ \item new function \code{rk.paste.JS.graph()} to simplify JS code generation for plots
+ }
+ }
+}
\section{Changes in rkwarddev version 0.05-6 (2012-05-10)}{
\subsection{added}{
\itemize{
Modified: trunk/rkward/packages/rkwarddev/inst/doc/rkwarddev_vignette.pdf
===================================================================
(Binary files differ)
Added: trunk/rkward/packages/rkwarddev/man/rk.paste.JS.graph.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rk.paste.JS.graph.Rd (rev 0)
+++ trunk/rkward/packages/rkwarddev/man/rk.paste.JS.graph.Rd 2012-09-29 21:36:41 UTC (rev 4330)
@@ -0,0 +1,61 @@
+\name{rk.paste.JS.graph}
+\alias{rk.paste.JS.graph}
+\title{Paste simple JavaScript plot code}
+\usage{
+ rk.paste.JS.graph(..., plotOpts = NULL,
+ printoutObj = NULL, level = 2, indent.by = "\t",
+ empty.e = FALSE)
+}
+\arguments{
+ \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{printoutObj}{An \code{rk.JS.var} object fetching
+ the \code{"code.printout"} modifier of \code{plotOpts}
+ (see examples below!).}
+}
+\value{
+ A character string.
+}
+\description{
+ This function is similar to \code{rk.paste.JS}, but adds
+ some code parts to its output which are commonly used to
+ generate plots with RKWard.
+}
+\details{
+ The contents of the \code{...} argument are evaluated by
+ \code{rk.paste.JS} and encapsulated between
+ \code{if(full)\{rk.graph.on()\} try(\{} and \code{\})
+ if(full)\{rk.graph.off()\}}. If generic plot options are
+ supplied, their \code{"code.preprocess"} and
+ \code{"code.calculate"} modifiers are also automatically
+ taken care of, so you only need to include
+ \code{"code.printout"} inside of \code{...}.
+}
+\examples{
+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")
+
+# 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(")"),
+ plotOpts=tmp.plot.options,
+ printoutObj=js.po.printout)
+
+cat(js.prnt)
+}
+\seealso{
+ \code{\link[rkwarddev:rk.paste.JS]{rk.paste.JS}}
+}
+
Modified: trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd
===================================================================
--- trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd 2012-09-29 15:13:30 UTC (rev 4329)
+++ trunk/rkward/packages/rkwarddev/man/rkwarddev-package.Rd 2012-09-29 21:36:41 UTC (rev 4330)
@@ -8,8 +8,8 @@
}
\details{
\tabular{ll}{ Package: \tab rkwarddev\cr Type: \tab
- Package\cr Version: \tab 0.05-6\cr Date: \tab
- 2012-05-10\cr Depends: \tab R (>= 2.9.0),methods,XiMpLe
+ Package\cr Version: \tab 0.05-7\cr Date: \tab
+ 2012-09-29\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
@@ -19,7 +19,7 @@
structures for RKWard.
}
\author{
- m.eik michalke \email{meik.michalke at hhu.de}
+ Meik Michalke \email{meik.michalke at hhu.de}
}
\keyword{package}
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