Greetings,

I am currently writing a Java application which is in need of visualizing 2D 
aromatic hydrocarbons. My application is capable of outputting the graphs into 
SMILES notation which I then can visualize using a method similiar to this:
http://sourceforge.net/apps/mediawiki/cdk/index.php?title=Renderer_Tutorial-Single_Molecules

What I would like in addition, is to be able to highlight 4 or 5 atoms within 
the structure. These atoms are not necessarily connected, and I do not need to 
be able to highlight the bonds.

I found some info on highlighting bonds here:

http://sourceforge.net/apps/mediawiki/cdk/index.php?title=Renderer_Tutorial-Standard_Generators

Which at the bottom mentions:

" Highlighting of atoms and bonds is carried out by the atom and bond highlight 
generators, not surprisingly. Remember that these should be lower in the list 
to be rendered in the upper layers of the diagram. The shape and fill of the 
atom highlights can be controlled through the renderer model. "

However, when I look here
http://pele.farmbio.uu.se/nightly-1.3.1/cdk-javadoc-1.4.0/

in org.openscience.cdk.renderer.generators

There is no class by the name of Atom or Bond Highlight Generators. 
Additionally, I can't find it in my source code either (version 1.4.18).

I then found this website:

http://chemutils.florida.scripps.edu:8080/cdk-export/

which takes a SMILES string and displays it in your browser. It has the ability 
to accept another SMILES string which is contained within the first, and it 
will highlight it. I looked at their source code and took this:

"
            IAtom one = molecule.getAtom(0);
            IAtom two = molecule.getAtom(1);
            IAtom three = molecule.getAtom(2);

            RendererModel model = renderer.getRenderer2DModel();
            ((RendererModel.ExternalHighlightColor)
            
model.getParameter(RendererModel.ExternalHighlightColor.class)).setValue(Color.green);

            Map colorHash = new HashMap();
            colorHash.put(one, (Color)((RendererModel.ExternalHighlightColor)
            
model.getParameter(RendererModel.ExternalHighlightColor.class)).getValue());
            colorHash.put(two, (Color)((RendererModel.ExternalHighlightColor)
            
model.getParameter(RendererModel.ExternalHighlightColor.class)).getValue());
            colorHash.put(three, (Color)((RendererModel.ExternalHighlightColor)
            
model.getParameter(RendererModel.ExternalHighlightColor.class)).getValue());

    
((RendererModel.ColorHash)model.getParameter(RendererModel.ColorHash.class)).setValue(colorHash);
"
which was very close to what to what they had. I believe this should highlight 
the first 3 atoms of my molecule green, however there is no coloration in the 
final structure. If you want to see my entire ImageRenderer Class, I have it 
attached (I believe you should look to jButton1ActionPerformed method ).

Additionally, I'm unsure how the atom enumeration works. As in, will the first 
"C" in my SMILES structure always be molecule.getAtom(0)?

Thank you for your time,

Aaron Germuth
University of Northern British Columbia

Attachment: ImageRenderer.java
Description: ImageRenderer.java

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Cdk-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cdk-user

Reply via email to