Class ReactionEditUtils
- java.lang.Object
-
- chemaxon.marvin.modules.reaction.ReactionEditUtils
-
@PublicAPI public class ReactionEditUtils extends Object
Utility methods for editing molecules that contain reactions.The model should follow these rules:
- More than one arrow remains: model is not an
RxnMolecule.
- One arrow remains: model is an
RxnMolecule.
- No arrow remains: model is not an
RxnMolecule.
- More than one arrow remains: model is not an
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method 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, chemaxon.marvin.sketch.MolEditor editor)
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 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 twoMolecule
s for join.static int
reactionArrowCount(MDocument document)
Returns the number of reaction arrows in a molecule.
-
-
-
Method Detail
-
fixReaction
public static Molecule fixReaction(Molecule mol, boolean autoFragment)
Fixes a possibly broken reaction.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.
- Parameters:
mol
- The molecule to be fixed; must have a parent document.autoFragment
- Indicates that automatic reaction calculation is set to on.- Returns:
- The converted molecule or the original molecule if no modification happened.
-
fixReaction
public static Molecule fixReaction(Molecule mol, boolean autoFragment, chemaxon.marvin.sketch.MolEditor editor)
Fixes a possibly broken reaction.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.
- Parameters:
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.- Returns:
- The converted molecule or the original molecule if no modification happened.
-
fixReaction
public static Molecule fixReaction(Molecule mol, boolean autoFragment, CTransform3D transform, chemaxon.marvin.paint.internal.MolPainterCommon common)
Fixes a possibly broken reaction.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.
- Parameters:
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.- Returns:
- The converted molecule or the original molecule if no modification happened.
-
prepareForJoin
public static void prepareForJoin(Molecule host, Molecule guest)
Prepares twoMolecule
s for join. Converts eachMolecule
if needed, and the converted structure is set as the main molecule of the parentMDocument
of the correspondingMolecule
.- Parameters:
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.- See Also:
MolJoin
,ReactionEditUtils
-
reactionArrowCount
public static int reactionArrowCount(MDocument document)
Returns the number of reaction arrows in a molecule.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.
- Parameters:
document
- The parent document of a molecule.- Returns:
- The number of reaction arrows.
-
getReactionArrows
public static List<MPolyline> getReactionArrows(MDocument document)
Returns all the reaction arrows contained in a molecule, represented as MPolylines.- Parameters:
document
- The parent document.- Returns:
- A list of the reaction arrows.
-
areArrowsAndLikelyTheSame
public static boolean areArrowsAndLikelyTheSame(MPolyline arrow1, MPolyline arrow2)
Compares type and checks perfect equality of location.- Parameters:
arrow1
-arrow2
-- Returns:
- True if conditions are met.
-
initOldDocuments
public static void initOldDocuments(MDocument document, boolean isAutomatic)
Adds plus signs to a document if it is potentially an old reaction.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.- Parameters:
document
- The document to be fixed.isAutomatic
- Indicates if the automatic reaction calculations are set to on.
-
-