Monday, April 05, 2010

CDK-JChemPaint #3: rendering parameters

OK, one last CDK-JChemPaint tutorial for today (see #1 and #2). Rendering wasn't as much fun, if you could not tune it to your needs. JChemPaint has long had many rendering parameters, and one by one we are converting them to the new API. The following code is an modification to the first example, and adds some code to list all rendering parameters for the three used generators:
// generators make the image elements
List generators = new ArrayList();
generators.add(new BasicSceneGenerator());
generators.add(new BasicBondGenerator());
generators.add(new BasicAtomGenerator());

// the renderer needs to have a toolkit-specific font manager
IRenderer renderer = new AtomContainerRenderer(
  generators, new AWTFontManager()

// dump all parameters
for (IGenerator generator : renderer.getGenerators()) {
  for (IGeneratorParameter parameter : generator.getParameters()) {
    println "parameter: " +
      parameter.getClass().getName().substring(40) +
      " -> " +
The output will look something like:
parameter: BasicSceneGenerator$BackGroundColor -> java.awt.Color[r=255,g=255,b=255]
parameter: BasicSceneGenerator$Margin -> 10.0
parameter: BasicSceneGenerator$UseAntiAliasing -> true
parameter: BasicSceneGenerator$UsedFontStyle -> NORMAL
parameter: BasicSceneGenerator$FontName -> Arial
parameter: BasicBondGenerator$BondWidth -> 1.0
parameter: BasicBondGenerator$DefaultBondColor -> java.awt.Color[r=0,g=0,b=0]
parameter: BasicAtomGenerator$AtomColor -> java.awt.Color[r=0,g=0,b=0]
parameter: BasicAtomGenerator$AtomColorer -> org.openscience.cdk.renderer.color.CDK2DAtomColors@49aacd5f
parameter: BasicAtomGenerator$AtomRadius -> 8.0
parameter: BasicAtomGenerator$ColorByType -> true
parameter: BasicAtomGenerator$CompactShape -> SQUARE
parameter: BasicAtomGenerator$CompactAtom -> false
parameter: BasicAtomGenerator$KekuleStructure -> false
parameter: BasicAtomGenerator$ShowEndCarbons -> false


  1. Hi Egon!

    We've met at SWAT4LS last year and I would like to show you a new app I've developed in my research unit!

    Can you get in touch with me to