Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1131 Atom symbols background is always white

open
nobody
5
2012-10-08
2011-04-29
Nina Jeliazkova
No

Changing the background via setting BasicSceneGenerator.BackgroundColor.class parameter doesn't have any effect on the background of the atom symbols. They are always drawn on a white background. This seems to be because the code around line 100 in org.openscience.cdk.renderer.visitor.AWTDrawVisitor.java takes the default value (white), instead of retrieving the value set via the parameter .

cdk-jchempaint -18

line 100 org.openscience.cdk.renderer.visitor.AWTDrawVisitor.java
for (IGeneratorParameter<?> param :
new BasicSceneGenerator().getParameters()) {
if (param instanceof BasicSceneGenerator.BackgroundColor)
this.backgroundColor = (Color)param.getDefault();
}

Discussion

  •  
    Attachments
  • In fact, the background should really be transparent, I guess... but what is not solved yet is that the bond drawing must be clipped with the drawing area of the atom symbol. This requires two-pass rendering approach not currently implemented.

     
  • Ralf Stephan
    Ralf Stephan
    2012-05-24

    I don't think bond drawing is best clipped with the atom drawing area, but the bond should be shortened. I have a screenshot of a big wedge pointing from an H atom, where it was in fact clipped, like the H biting out a tooth from the wedge. That looks nearly as bad as not clipping.

     
  • Ralf, yes, bond shortening is even better! It's just really hard to decide how much shorter they should become, which involves knowing the font size etc...

    Arvid and I have been talking for too long now about the 2-pass process, where an initial pass would result in estimated sizes of rendering elements, which could be used in the second pass to adjust things accordingly.

    That is, in the first pass, the font size could be calculated so that in the second pass the bond length can be calculated more accurately, based on those initial properties.

     
  • Ralf Stephan
    Ralf Stephan
    2012-07-29

    You can see how it looks in the SVG implementation. I'm doing even 3 passes but that's for SVG efficiency. At least, you can take some algorithms/methods directly from that code.