public class StructureDiagramGenerator extends Object
new StructureDiagramGenerator().generateCoordinates(molecule);The older versions of the API suggested using the following a set/generate/get idiom but this performs an unnecessary (in most cases) copy.
StructureDiagramGenerator sdg = new StructureDiagramGenerator(); sdg.setMolecule(molecule); // cloned! sdg.generateCoordinates(); molecule = sdg.getMolecule();This idiom only needs to be used when 'fixing' parts of an existing layout with
setMolecule(IAtomContainer, boolean, Set, Set)
Modifier and Type | Field and Description |
---|---|
static Comparator<IAtomContainer> |
LARGEST_FIRST_COMPARATOR |
Constructor and Description |
---|
StructureDiagramGenerator()
The empty constructor.
|
StructureDiagramGenerator(IAtomContainer molecule)
Creates an instance of this class while assigning a molecule to be layed
out.
|
Modifier and Type | Method and Description |
---|---|
void |
generateCoordinates()
The main method of this StructurDiagramGenerator.
|
void |
generateCoordinates(IAtomContainer mol)
Convenience method for generating 2D coordinates.
|
void |
generateCoordinates(IReaction reaction)
Convenience method to generate 2D coordinates for a reaction.
|
void |
generateCoordinates(javax.vecmath.Vector2d firstBondVector)
The main method of this StructurDiagramGenerator.
|
void |
generateExperimentalCoordinates()
Deprecated.
|
void |
generateExperimentalCoordinates(javax.vecmath.Vector2d firstBondVector)
Deprecated.
|
double |
getBondLength()
Returns the bond length used for laying out the molecule.
|
IAtomContainer |
getMolecule()
Returns the molecule, usually used after a call of generateCoordinates()
|
IAtom |
getOtherBondAtom(IAtom atom,
IBond bond)
Returns the other atom of the bond.
|
TemplateHandler |
getTemplateHandler()
Deprecated.
always null, substructure templates are not used anymore
|
boolean |
getUseTemplates()
Deprecated.
always false, substructure templates are not used anymore
|
void |
setAlignMappedReaction(boolean align)
Set whether reaction reactants should be allignned to their product.
|
void |
setBondLength(double bondLength)
Deprecated.
|
void |
setMolecule(IAtomContainer molecule)
Assings a molecule to be layed out.
|
void |
setMolecule(IAtomContainer mol,
boolean clone) |
void |
setMolecule(IAtomContainer mol,
boolean clone,
Set<IAtom> afix,
Set<IBond> bfix)
Assigns a molecule to be laid out.
|
void |
setTemplateHandler(TemplateHandler templateHandler)
Deprecated.
substructure templates are no longer used for layout but those provided here
will be converted to identity templates
|
void |
setUseIdentityTemplates(boolean use)
Set whether identity templates are used.
|
void |
setUseTemplates(boolean useTemplates)
Deprecated.
always false, substructure templates are not used anymore
|
public static final Comparator<IAtomContainer> LARGEST_FIRST_COMPARATOR
public StructureDiagramGenerator()
public StructureDiagramGenerator(IAtomContainer molecule)
molecule
- The molecule to be layed out.public final void generateCoordinates(IAtomContainer mol) throws CDKException
Convenience method for generating 2D coordinates.
The method is short-hand for calling:
sdg.setMolecule(mol, false); sdg.generateCoordinates();
mol
- molecule to layoutCDKException
- problem with layoutpublic final void generateCoordinates(IReaction reaction) throws CDKException
Convenience method to generate 2D coordinates for a reaction. If atom-atom maps are present on a reaction, the substructures are automatically aligned.
This feature can be disabled by changing the setAlignMappedReaction(boolean)
reaction
- reaction to layoutCDKException
- problem with layoutpublic void setMolecule(IAtomContainer mol, boolean clone)
public void setMolecule(IAtomContainer mol, boolean clone, Set<IAtom> afix, Set<IBond> bfix)
mol
- the molecule for which coordinates are to be generated.clone
- Should the whole process be performed with a cloned copy?afix
- Atoms that should be fixed in place, coordinates are not changed.bfix
- Bonds that should be fixed in place, they will not be flipped, bent, or streched.@Deprecated public void setUseTemplates(boolean useTemplates)
useTemplates
- set true to use templates, false otherwisepublic void setUseIdentityTemplates(boolean use)
use
- whether to use identity templates@Deprecated public boolean getUseTemplates()
@Deprecated public void setTemplateHandler(TemplateHandler templateHandler)
templateHandler
- The new templateHandler value@Deprecated public TemplateHandler getTemplateHandler()
public void setMolecule(IAtomContainer molecule)
molecule
- the molecule for which coordinates are to be generated.public void setAlignMappedReaction(boolean align)
align
- align settingpublic IAtomContainer getMolecule()
@Deprecated public void generateExperimentalCoordinates() throws CDKException
generateCoordinates()
CDKException
- if an error occursgenerateCoordinates(org.openscience.cdk.interfaces.IAtomContainer)
@Deprecated public void generateExperimentalCoordinates(javax.vecmath.Vector2d firstBondVector) throws CDKException
generateCoordinates()
firstBondVector
- the vector of the first bond to lay outCDKException
- if an error occurspublic void generateCoordinates(javax.vecmath.Vector2d firstBondVector) throws CDKException
firstBondVector
- The vector of the first bond to lay outCDKException
- if an error occurspublic void generateCoordinates() throws CDKException
CDKException
- if an error occurs@Deprecated public void setBondLength(double bondLength)
GeometryUtil.scaleMolecule(IAtomContainer, double)
GeometryUtil.scaleMolecule(IAtomContainer, double)
.
IAtomContainer mol = ...; sdg.generateCoordinates(mol); int targetBondLength = 28; double factor = targetBondLength/GeometryUtil.getMedianBondLength(mol); GeometryUtil.scaleMolecule(mol, factor);
bondLength
- The new bondLength valueUnsupportedOperationException
- not supportedpublic double getBondLength()
public IAtom getOtherBondAtom(IAtom atom, IBond bond)
atom
- the atom we already havebond
- the bondCopyright © 2021. All rights reserved.