Skip to content

Commit

Permalink
Make it an option to omit major isotopes depiction (default will be t…
Browse files Browse the repository at this point in the history
…o include them)
  • Loading branch information
johnmay committed Sep 11, 2017
1 parent afb7a68 commit d8cd6d6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Expand Up @@ -30,6 +30,7 @@
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IIsotope;
import org.openscience.cdk.interfaces.IPseudoAtom;
import org.openscience.cdk.renderer.RendererModel;
import org.openscience.cdk.renderer.generators.standard.AbbreviationLabel.FormattedText;

import java.awt.Font;
Expand Down Expand Up @@ -111,9 +112,10 @@ private StandardAtomGenerator(Font font, double adjunctSpacing, double scriptSiz
* @param container structure to which the atom belongs
* @param atom the atom to generate the symbol for
* @param position the hydrogen position
* @param model additional rendering options
* @return atom symbol
*/
AtomSymbol generateSymbol(IAtomContainer container, IAtom atom, HydrogenPosition position) {
AtomSymbol generateSymbol(IAtomContainer container, IAtom atom, HydrogenPosition position, RendererModel model) {
if (atom instanceof IPseudoAtom) {
IPseudoAtom pAtom = (IPseudoAtom) atom;
if (pAtom.getAttachPointNum() <= 0)
Expand All @@ -127,7 +129,9 @@ AtomSymbol generateSymbol(IAtomContainer container, IAtom atom, HydrogenPosition

// unset the mass if it's the major isotope (could be an option)
Integer mass = atom.getMassNumber();
if (mass != null && isMajorIsotope(number, mass)) {
if (mass != null &&
model.get(StandardGenerator.OmitMajorIsotopes.class) &&
isMajorIsotope(number, mass)) {
mass = null;
}

Expand Down
Expand Up @@ -371,7 +371,7 @@ private AtomSymbol[] generateAtomSymbols(IAtomContainer container,
if (remapped) {
symbols[i] = atomGenerator.generateAbbreviatedSymbol(symbolRemap.get(atom), hPosition);
} else {
symbols[i] = atomGenerator.generateSymbol(container, atom, hPosition);
symbols[i] = atomGenerator.generateSymbol(container, atom, hPosition, parameters);
}

if (symbols[i] != null) {
Expand Down Expand Up @@ -1072,4 +1072,16 @@ public Double getDefault() {
return 0.6;
}
}

/**
* Whether Major Isotopes e.g. 12C, 16O should be omitted.
*/
public static final class OmitMajorIsotopes extends AbstractGeneratorParameter<Boolean> {

/**{@inheritDoc} */
@Override
public Boolean getDefault() {
return false;
}
}
}

0 comments on commit d8cd6d6

Please sign in to comment.