@PublicAPI public class ReactionEditUtils extends java.lang.Object
The model should follow these rules:
RxnMolecule.
RxnMolecule.
RxnMolecule.
Modifier and Type | Method and Description |
---|---|
static boolean |
areArrowsAndLikelyTheSame(MPolyline arrow1,
MPolyline arrow2)
Compares type and checks perfect equality of location.
|
static Molecule |
fixReaction(Molecule mol,
boolean autoFragment)
Fixes a possibly broken reaction.
|
static Molecule |
fixReaction(Molecule mol,
boolean autoFragment,
CTransform3D transform,
chemaxon.marvin.paint.internal.MolPainterCommon common)
Fixes a possibly broken reaction.
|
static Molecule |
fixReaction(Molecule mol,
boolean autoFragment,
chemaxon.marvin.sketch.MolEditor editor)
Fixes a possibly broken reaction.
|
static java.util.List<MPolyline> |
getReactionArrows(MDocument document)
Returns all the reaction arrows contained in a molecule, represented as MPolylines.
|
static void |
initOldDocuments(MDocument document,
boolean isAutomatic)
Adds plus signs to a document if it is potentially an old reaction.
|
static void |
prepareForJoin(Molecule host,
Molecule guest)
Prepares two
Molecule s for join. |
static int |
reactionArrowCount(MDocument document)
Returns the number of reaction arrows in a molecule.
|
public static Molecule fixReaction(Molecule mol, boolean autoFragment)
If the molecule model is a single-, multi-, or no-step reaction (reaction arrow has just been deleted), it is converted to a non-reaction.
If the molecule model is not a reaction, but there is exactly one arrow, it is converted to a reaction.
The main molecule graph of the molecule’s parent documet will be set to the new molecule.
mol
- The molecule to be fixed; must have a parent document.autoFragment
- Indicates that automatic reaction calculation is set to on.public static Molecule fixReaction(Molecule mol, boolean autoFragment, chemaxon.marvin.sketch.MolEditor editor)
If the molecule model is a single-, multi-, or no-step reaction (reaction arrow has just been deleted), it is converted to a non-reaction.
If the molecule model is not a reaction, but there is exactly one arrow, it is converted to a reaction.
The main molecule graph of the molecule’s parent documet will be set to the new molecule.
mol
- The molecule to be fixed; must have a parent document.autoFragment
- Indicates that automatic reaction calculation is set to on.editor
- Contains GUI information to calculate ReactionPlusSign.public static Molecule fixReaction(Molecule mol, boolean autoFragment, CTransform3D transform, chemaxon.marvin.paint.internal.MolPainterCommon common)
If the molecule model is a single-, multi-, or no-step reaction (reaction arrow has just been deleted), it is converted to a non-reaction.
If the molecule model is not a reaction, but there is exactly one arrow, it is converted to a reaction.
The main molecule graph of the molecule’s parent documet will be set to the new molecule.
mol
- The molecule to be fixed; must have a parent document.autoFragment
- Indicates that automatic reaction calculation is set to on.transform
- To calculate ReactionPlusSign.common
- To calculate ReactionPlusSign.public static void prepareForJoin(Molecule host, Molecule guest)
Molecule
s for join. Converts each Molecule
if needed, and the converted structure is set as the main molecule of the
parent MDocument
of the corresponding Molecule
.host
- The host molecule with which the other molecule is merged. Usually the content of the canvas.guest
- The guest molecule with which the host molecule is merged.MolJoin
,
ReactionEditUtils
public static int reactionArrowCount(MDocument document)
Note: a molecule is supposed to contain only one MRArrow object, but any number of arrows represented as MPolyline. If there are multiple MRArrow objects in the passed molecule, they will be counted as a single MRarrow. The returned value will be the sum of the arrows represented by MPolylines plus 1 if there are any number of MRArrows contained in the molecule.
document
- The parent document of a molecule.public static java.util.List<MPolyline> getReactionArrows(MDocument document)
document
- The parent document.public static boolean areArrowsAndLikelyTheSame(MPolyline arrow1, MPolyline arrow2)
arrow1
- arrow2
- public static void initOldDocuments(MDocument document, boolean isAutomatic)
A document is potentially an old reaction if there are multiple
components on either side of the reaction, but there are no calculated
MReactionSign
objects.
document
- The document to be fixed.isAutomatic
- Indicates if the automatic reaction calculations are set to on.