{
  "version": "https://jsonfeed.org/version/1.1",
  "title": "chem-bla-ics",
  "description": "Chemblaics (pronounced chem-bla-ics) is the science that uses open science and computers to solve problems in chemistry, biochemistry and related fields.",
  "home_page_url": "https://chem-bla-ics.linkedchemistry.info/",
  "feed_url": "https://chem-bla-ics.linkedchemistry.info/2011/06/12/cdk-jchempaint-7-rendering-molecules-as.json",
  "icon": "https://chem-bla-ics.linkedchemistry.info/assets/images/chem-bla-ics_logo.png",
  "language": "en",
  "authors": [
    {
      "name": "Egon Willighagen",
      "url": "https://orcid.org/0000-0001-7542-0286",
      "_orcid": "0000-0001-7542-0286"
    }
  ],
  "items": [

    {
      "id": "https://doi.org/10.59350/qs03g-8f627",
      "url": "https://chem-bla-ics.linkedchemistry.info/2011/06/12/cdk-jchempaint-7-rendering-molecules-as.html",
      "title": "CDK-JChemPaint #7: rendering molecules as SVG",
      "content_html": "<p>A very long time ago, <a href=\"http://sv.wikipedia.org/wiki/Scalable_Vector_Graphics\">Scalable Vector Graphics</a>\npromised to revolutionalize images on the web. After initial cool work (including\n<a href=\"http://www.dspace.cam.ac.uk/handle/1810/746\">CMLSnap</a>: animated chemical reactions\nby Peter’s group!), things cooled down. There was simply a <strong>lack of support\nin browsers</strong>. Things have changed. SVG is much better supported now, and people\nare starting to use SVG again. Like Noel, <a href=\"http://baoilleach.blogspot.com/2011/06/molecular-zooming-with-open-babel-svg.html\">visualizing 100 molecules in one\nblog post</a>.</p>\n\n<p>The new CDK-JChemPaint code has been refactored such that the original code\nfor the core functionality is now independent from the drawing toolkit. And\nwe have two well-developed implementations, one for Swing/AWT (used by the <a href=\"http://jchempaint.sf.net/\">JChemPaint</a>\napplet), and one for SWT (used by <a href=\"http://www.bioclipse.net/\">Bioclipse</a>). And\nthere is one that generates SVG too, written by <a href=\"http://gilleain.blogspot.com/\">Gileain</a>\nas a proof of principle.</p>\n\n<p>The code is almost identical to the code for <a href=\"https://chem-bla-ics.linkedchemistry.info/2010/04/05/cdk-jchempaint-1-rendering-molecules.html\">rendering molecules as PNG <i class=\"fa-solid fa-recycle fa-xs\"></i></a>.\nWe just swap the AWTDrawVisitor for the SVGGenerator:</p>\n\n<pre>-renderer.paint(triazole, new AWTDrawVisitor(g2));\n+svgGenerator = new SVGGenerator();\n+renderer.paint(triazole, svgGenerator);\n</pre>\n\n<p>Additionally, we need to change how we output the results. The below code generate\nthe SVG and the matching HTML snippet:</p>\n\n<pre>new File(\"triazole.svg\").append(svgGenerator.getResult())\n\nfile = new PrintWriter(new FileWriter(new File(\"triazole.html\")))\nfile.println(\"&lt;html&gt;\");\nfile.println(\"&lt;body&gt;\");\nfile.print(\"&lt;embed width=\\\"100\\\" height=\\\"100\\\" src=\\\"triazole.svg\\\" /&gt;\");\nfile.println(\"&lt;/body&gt;\");\nfile.println(\"&lt;html&gt;\");\nfile.close()\n</pre>\n\n<p>The result looks like:</p>\n\n<embed width=\"100\" height=\"100\" src=\"/assets/images/triazole.svg\" />\n\n<p>I did have to tweak the SVG generated with <a href=\"https://sourceforge.net/projects/cdk/files/CDK-JChemPaint/20/\">CDK-JChemPaint 20</a>,\nso that the HTML ensures the initial scaling, by removing the width and height\nin the SVG (patch pending). But this output also nicely shows that there are\nglitches in the generated code. I hope people are interested in contributing\nto this part of the CDK-JChemPaint patch!</p>\n\n<p>The full source code of the <em>svgMol.groovy</em> can be found in the <a href=\"https://github.com/egonw/groovy-jcp\">Groovy JChemPaint\nrepository</a>.</p>",
      "summary": "A very long time ago, Scalable Vector Graphics promised to revolutionalize images on the web. After initial cool work (including CMLSnap: animated chemical reactions by Peter’s group!), things cooled down. There was simply a lack of support in browsers. Things have changed. SVG is much better supported now, and people are starting to use SVG again. Like Noel, visualizing 100 molecules in one blog post.",
      "image": "https://chem-bla-ics.linkedchemistry.info/assets/images/triazole.svg",
      "date_published": "2011-06-12T00:00:00+00:00",
      "date_modified": "2026-12-05T00:00:00+00:00",
      "tags": ["cdk","groovy","jchempaint"],
      
      
      
      
      
      
        "authors": [ { "name": "Egon Willighagen", "url": "https://orcid.org/0000-0001-7542-0286" } ]
      
    }

  ]
}
