Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Molecule titles as Bounds #975

Open
parit opened this issue Jun 1, 2023 · 3 comments
Open

Molecule titles as Bounds #975

parit opened this issue Jun 1, 2023 · 3 comments

Comments

@parit
Copy link

parit commented Jun 1, 2023

Hello,
I was going through the code for org.openscience.cdk.depict.DepictionGenerator for drawing a reaction as svg. I noticed that a molecule's title is generated as a <path> element in the resulting svg instead of a usual <text>. Reading through the code, I noticed that titles are interpreted as org.openscience.cdk.renderer.elements.Bounds instead of org.openscience.cdk.renderer.elements.TextElement.

final Bounds title = copy.getParameterValue(BasicSceneGenerator.ShowReactionTitle.class) ? copy.generateTitle(rxn, scale) : emptyBounds;

I am not sure why is this the case. Maybe someone from the cdk developers could throw light on this. My problem is that my titles are HTML strings with <sub> <sup> tags in there. These are not rendered correctly in the resulting svg.

@johnmay
Copy link
Member

johnmay commented Jun 2, 2023

We renderer them as paths otherwise we don’t have correct sizing information and we want things to be consistent. We could make an option to not do this for the title though.

A work around is to use Unicode sub/super scripts instead of HTML.
What I prefer to do is just not embedded the title, check out the advanced options on cdkdepict (www.simolecule.com/cdkdepict) you can embedded the title or render it in HTML

@parit
Copy link
Author

parit commented Jun 6, 2023

Hello @johnmay I checked the cdkdepict, my problem is that I am rendering an entire reaction, so can't use the similar logic of showing the name at the bottom is each molecule (as is in the example) without embedding it. Do you know a way to associate metadata like custom class name to the <g> tag surrounding the title? Right now there is no way to associate title to the molecule in the svg.
10001

@johnmay
Copy link
Member

johnmay commented Jun 6, 2023

There is no way to currently do it then, a new option "NonRenderedTitle" option which by passes the rendering would do the trick. Please feel free to submit a patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants