aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2017-06-13 16:05:39 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2017-06-13 16:05:39 +0200
commit3f82707cd1e974848185b1141c69734e2573594d (patch)
tree42b968e860f8748280d2d217a1b24831f9d06970
parentf5b36dc73e7778091a08eaed51fd9d4f8677fbc1 (diff)
Make grConvert optional as it vanished on Windows
-rw-r--r--ChangeLog6
-rw-r--r--DESCRIPTION10
-rw-r--r--R/chent.R36
3 files changed, 31 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index 767fc23..fcd9305 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+commit f5b36dc73e7778091a08eaed51fd9d4f8677fbc1
+Author: Johannes Ranke <jranke@uni-bremen.de>
+Date: 2017-03-17 21:19:14 +0100
+
+ Support a common template for depictions
+
commit 13c59928390dd38073c7664ea1d2961d11ba60e2
Author: Johannes Ranke <jranke@uni-bremen.de>
Date: 2017-03-15 15:16:34 +0100
diff --git a/DESCRIPTION b/DESCRIPTION
index c311ded..eb8cc73 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -2,7 +2,7 @@ Package: chents
Type: Package
Title: Chemical Entities as R Objects
Version: 0.2-6
-Date: 2017-03-17
+Date: 2017-06-13
Authors@R: c(person("Johannes", "Ranke", role = c("aut", "cre", "cph"),
email = "jranke@uni-bremen.de"))
Description: Utilities for dealing with chemical entities and associated
@@ -13,17 +13,17 @@ Description: Utilities for dealing with chemical entities and associated
Imports:
webchem,
R6,
- grImport,
- grConvert,
yaml
Suggests:
knitr,
testthat,
- PythonInR
+ PythonInR,
+ grImport,
+ grConvert
License: GPL
LazyLoad: yes
LazyData: yes
Encoding: UTF-8
VignetteBuilder: knitr
URL: http://cgit.jrwb.de/chents
-RoxygenNote: 5.0.1.9000
+RoxygenNote: 6.0.1
diff --git a/R/chent.R b/R/chent.R
index 192c6df..3e89e14 100644
--- a/R/chent.R
+++ b/R/chent.R
@@ -191,22 +191,26 @@ chent <- R6Class("chent",
PythonInR::pyExec("d2d.DrawMolecule(mol)")
PythonInR::pyExec("d2d.FinishDrawing()")
self$svg <- PythonInR::pyGet("d2d.GetDrawingText()")
- svgfile <- tempfile(fileext = ".svg")
- writeLines(self$svg, svgfile)
-
- # Convert to PostScript, remembering size properties
- psfile <- tempfile(fileext = ".ps")
- suppressMessages(grConvert::convertPicture(svgfile, psfile))
- ps_font_line <- grep("Tm$", readLines(psfile), value = TRUE)[1]
- ps_font_size <- gsub(" .*$", "", ps_font_line)
- self$Pict_font_size = as.numeric(ps_font_size)
-
- # Read in to create Picture
- xmlfile <- tempfile(fileext = ".xml")
- PostScriptTrace(psfile, outfilename = xmlfile)
- unlink(paste0("capture", basename(psfile)))
- self$Picture <- readPicture(xmlfile)
- unlink(c(xmlfile, psfile, svgfile))
+
+ if (!requireNamespace("grConvert")) {
+ stop("grConvert is not available, self$Picture will not be created")
+ } else {
+ # Convert to PostScript, remembering size properties
+ svgfile <- tempfile(fileext = ".svg")
+ writeLines(self$svg, svgfile)
+ psfile <- tempfile(fileext = ".ps")
+ suppressMessages(grConvert::convertPicture(svgfile, psfile))
+ ps_font_line <- grep("Tm$", readLines(psfile), value = TRUE)[1]
+ ps_font_size <- gsub(" .*$", "", ps_font_line)
+ self$Pict_font_size = as.numeric(ps_font_size)
+
+ # Read in to create Picture
+ xmlfile <- tempfile(fileext = ".xml")
+ PostScriptTrace(psfile, outfilename = xmlfile)
+ unlink(paste0("capture", basename(psfile)))
+ self$Picture <- readPicture(xmlfile)
+ unlink(c(xmlfile, psfile, svgfile))
+ }
}
},
get_chyaml = function(repo = c("wd", "local", "web"),

Contact - Imprint