Skip to content

Commit 5766f49

Browse files
committed
Update SDG doc to show better usage pattern.
1 parent 58fe7f3 commit 5766f49

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

tool/sdg/src/main/java/org/openscience/cdk/layout/StructureDiagramGenerator.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,25 @@
7979
import java.util.Set;
8080

8181
/**
82-
* Generates 2D coordinates for a molecule for which only connectivity is known
83-
* or the coordinates have been discarded for some reason. Usage: Create an
84-
* instance of this class, thereby assigning a molecule, call
85-
* generateCoordinates() and get your molecule back:
82+
* Generates 2D coordinates for a molecule.
83+
*
84+
* <b>Basic Usage:</b>
85+
* If you just want to generate coordinate for a molecule (or reaction) you
86+
* can use the following one-liner:
87+
* <pre>
88+
* new StructureDiagramGenerator().generateCoordinates(molecule);
89+
* </pre>
90+
* The older versions of the API using the following a set/generate/get idiom
91+
* but this performs an unnecessary (in most cases) copy.
8692
* <pre>
8793
* StructureDiagramGenerator sdg = new StructureDiagramGenerator();
88-
* sdg.setMolecule(someMolecule);
94+
* sdg.setMolecule(molecule); // cloned!
8995
* sdg.generateCoordinates();
90-
* IAtomContainer layedOutMol = sdg.getMolecule();
96+
* molecule = sdg.getMolecule();
9197
* </pre>
92-
*
93-
* <p>The method will fail if the molecule is disconnected. The
94-
* partitionIntoMolecules(AtomContainer) can help here.
98+
* This idiom only needs to be used when 'fixing' parts of an existing
99+
* layout: {@link #setMolecule(IAtomContainer, boolean, Set, Set)}
100+
* <br/>
95101
*
96102
* @author steinbeck
97103
* @cdk.created 2004-02-02
@@ -104,7 +110,6 @@
104110
* @cdk.githash
105111
* @cdk.bug 1536561
106112
* @cdk.bug 1788686
107-
* @see org.openscience.cdk.graph.ConnectivityChecker#partitionIntoMolecules(IAtomContainer)
108113
*/
109114
public class StructureDiagramGenerator {
110115

0 commit comments

Comments
 (0)