chemaxon.struc.graphics
Class MEFlow

java.lang.Object
  extended by chemaxon.struc.MObject
      extended by chemaxon.struc.graphics.MPolyline
          extended by chemaxon.struc.graphics.MEFlow
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class MEFlow
extends MPolyline

Electron flow arrow.
Representing the movement of one or two electrons in a reaction as a curved arrow.
Electron flow can start from any atom or bond, but not from any atom pairs that has no connection bond.
The logic of the electron flows:

Since:
Marvin 3.5, 07/14/2004
Version:
5.5
Author:
Peter Csizmadia, Peter Vadasz
See Also:
Serialized Form

Field Summary
static int E_SINK
          Electron sink.
static int E_SOURCE
          Electron source.
 
Fields inherited from class chemaxon.struc.graphics.MPolyline
ARROW_BACK_FLAG, ARROW_CROSSED_FLAG, ARROW_CURVED_FLAG, ARROW_DASHED_FLAG, ARROW_EQUILIBRIUM_FLAG, ARROW_GROUP1_MASK, ARROW_GROUP2_MASK, ARROW_HALF_LEFT, ARROW_HALF_MASK, ARROW_HALF_RIGHT, ARROW_RETROSYNTHETIC_FLAG, arrowFlags, CLOSED_FLAG, DEFAULT_ARROW_HEAD_LENGTH, DEFAULT_ARROW_HEAD_WIDTH, DEFAULT_THICKNESS, HEAD, points, TAIL, THICKNESS_SET_FLAG
 
Fields inherited from class chemaxon.struc.MObject
PAINT_ANTIALIAS, PAINT_FOCUSED, TRANSFORM_DISTORT
 
Constructor Summary
  MEFlow()
          Contructs an empty electron flow arrow.
  MEFlow(int ne)
          Contructs an empty electron flow arrow.
protected MEFlow(MEFlow l)
          Copy constructor.
  MEFlow(MPoint p1, MPoint p2, int ne)
          Contructs an electron flow arrow with the specified endpoints.
 
Method Summary
 java.lang.Object clone()
          Creates a clone.
static MolAtom getAtom(java.lang.Object terminus)
          Gets the atom at the terminus of an arrow.
static MolAtom[] getAtoms(java.lang.Object terminus)
          Gets the atom or atoms at the terminus of an arrow.
static MolBond getBond(java.lang.Object terminus)
          Gets the bond at the terminus of an arrow.
 java.lang.Object getMolObject(int i)
          Gets the electron source or sink.
 int getNumElectrons()
          Gets the number of electrons the arrow represents.
 MPoint getPoint(int i)
          Gets a point of the line.
 int getPointRefCount()
          Gets the number of point references.
 java.lang.Object getSink()
          Gets the destination of the electron-flow arrow (MolAtom, MolBond, or MolAtom[2] for incipient bond).
 MolAtom getSinkAtom()
          Gets the atom at the sink of this arrow.
 MolAtom[] getSinkAtoms()
          Gets the atom or atoms at the arrow sink.
 MolBond getSinkBond()
          Gets the bond at the sink of this arrow.
 java.lang.Object getSource()
          Gets the origin of the electron-flow arrow (MolAtom or MolBond).
 MolAtom getSourceAtom()
          Gets the atom at the source of this arrow.
 MolAtom[] getSourceAtoms()
          Gets the atom or atoms at the arrow source.
 MolBond getSourceBond()
          Gets the bond at the source of this arrow.
static MolAtom[][] getValidSinkAtomPairsForMolecule(Molecule m, MolAtom source)
          Returns the atom pairs can be chosen as a sink for an electron flow with a MolAtom as a source in the molecule.
static MolAtom[][] getValidSinkAtomPairsForMolecule(Molecule m, MolBond source)
          Returns the atom pairs can be chosen as a sink for an electron flow with a MolBond as a source in the molecule.
static MolAtom[] getValidSinkAtomsForMolecule(Molecule m, MolAtom source)
          Returns the atoms can be chosen as a sink for an electron flow with a MolAtom as a source in the molecule.
static MolAtom[] getValidSinkAtomsForMolecule(Molecule m, MolBond source)
          Returns the atoms can be chosen as a sink for an electron flow with a MolBomd as a source in the molecule.
static MolBond[] getValidSinkBondsForMolecule(Molecule m, MolAtom source)
          Returns the bonds can be chosen as a sink for an electron flow with a MolAtom as a source in the molecule.
static MolBond[] getValidSinkBondsForMolecule(Molecule m, MolBond source)
          Returns the bonds can be chosen as a sink for an electron flow with a MolBond as a source in the molecule.
static MolAtom[][] getValidSourceAtomPairsForMolecule(Molecule m)
          Returns the atom pairs can be chosen as incipient bonds as a source for an electron flow in the molecule.
static MolAtom[] getValidSourceAtomsForMolecule(Molecule m)
          Returns the atoms can be chosen as a source for an electron flow in the molecule.
static MolBond[] getValidSourceBondsForMolecule(Molecule m)
          Returns the bonds can be chosen as a source for an electron flow in the molecule.
static boolean isAtom(java.lang.Object terminus)
          Gets whether the arrow's terminus is at an atom.
static boolean isBond(java.lang.Object terminus)
          Gets whether the arrow's terminus is at a bond.
static boolean isIncipBond(java.lang.Object sink)
          Gets whether the arrow's sink is at an incipient bond.
static boolean isValidSourceAndSinkForMolecule(java.lang.Object source, java.lang.Object sink, Molecule m)
          Checks if the given Objects can be a source and sink of a electron flow in the molecule.
static boolean isValidSourceForMolecule(java.lang.Object source, Molecule m)
          Checks if the given Object can be a source of a electron flow in the molecule.
 boolean sinkIsAtom()
          Gets whether this arrow's sink is an atom.
 boolean sinkIsBond()
          Gets whether this arrow's sink is a bond.
 boolean sinkIsIncipBond()
          Gets whether this arrow's sink is an incipient bond.
 boolean sourceIsAtom()
          Gets whether this arrow's source is an atom.
 boolean sourceIsBond()
          Gets whether this arrow's source is a bond.
 
Methods inherited from class chemaxon.struc.graphics.MPolyline
addAttributeKeys, calcCenter, checkValidity, containsAtom, copyProperties, distanceFrom, finishCloning, fixClonedPoints, fixMidPointClones, getArcAngle, getArcCenter, getArcRadius, getArcRadius, getArrowFlags, getArrowLength, getArrowWidth, getAttribute, getFlags, getMidPointLocation, getMirroredArrowFlags, getPointCount, getPointRef, getPoints, getSkip, getThickness, hasBackground, hasColor, hasFace, hasLineColor, hasOutline, isArrow, isEmpty, isThicknessSet, removeChild, replaceAtom, reverse, rotate, setArcAngle, setArrow, setArrowFlags, setArrowLength, setArrowWidth, setAttribute, setFlags, setPoints, setSkip, setThickness, transform, unselectContents, updateBoundingRect
 
Methods inherited from class chemaxon.struc.MObject
addCdataAttributeKeys, addNotify, containsPoint, distanceFrom, getBackground, getColor, getLineColor, isChildOf, isInternalSelectable, isReactionArrow, isSelectableNow, isSelected, isTransformable, makeColor, removeAtom, removeNotify, setBackground, setColor, setLineColor, setSelected, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

E_SOURCE

public static final int E_SOURCE
Electron source.

See Also:
getMolObject(int), Constant Field Values

E_SINK

public static final int E_SINK
Electron sink.

See Also:
getMolObject(int), Constant Field Values
Constructor Detail

MEFlow

public MEFlow()
Contructs an empty electron flow arrow.


MEFlow

public MEFlow(int ne)
Contructs an empty electron flow arrow.

Parameters:
ne - one-electron (1) or two-electron (2) transfer

MEFlow

public MEFlow(MPoint p1,
              MPoint p2,
              int ne)
Contructs an electron flow arrow with the specified endpoints.

Parameters:
p1 - the starting point
p2 - the endpoint
ne - one-electron (1) or two-electron (2) transfer
See Also:
MAtomSetPoint

MEFlow

protected MEFlow(MEFlow l)
Copy constructor.

Parameters:
l - the original arrow
Method Detail

getNumElectrons

public int getNumElectrons()
Gets the number of electrons the arrow represents.

Returns:
1 or 2

getPoint

public MPoint getPoint(int i)
Gets a point of the line.

Overrides:
getPoint in class MPolyline
Parameters:
i - the point index
Returns:
the point's clone

clone

public java.lang.Object clone()
Description copied from class: MObject
Creates a clone.

Overrides:
clone in class MPolyline
Returns:
the clone

getMolObject

public java.lang.Object getMolObject(int i)
Gets the electron source or sink.

Parameters:
i - E_SOURCE or E_SINK
Returns:
a MolAtom, MolBond or MolAtom[2] (incipient bond) object

getPointRefCount

public int getPointRefCount()
Gets the number of point references.

Overrides:
getPointRefCount in class MPolyline
Returns:
2 because middle point is not needed

getValidSourceAtomsForMolecule

public static MolAtom[] getValidSourceAtomsForMolecule(Molecule m)
Returns the atoms can be chosen as a source for an electron flow in the molecule. All atoms in the Molecule can be selected as source.

Parameters:
m - the molecule
Returns:
the atoms in the molecule can be selected as source.

getValidSinkAtomsForMolecule

public static MolAtom[] getValidSinkAtomsForMolecule(Molecule m,
                                                     MolAtom source)
Returns the atoms can be chosen as a sink for an electron flow with a MolAtom as a source in the molecule. If the source is in an sgroup and not the attachment point, then only the atoms in the sgroup can be selected. Atoms in a superatom-sgroup other than the attachment point can not be a sink if the source is outside of the sgroup. All other cases all atoms can be sink.

Parameters:
m - the molecule
source - the source of the electron flow in the molecule.
Returns:
the atoms in the molecule can be sink for this electron flow, or empty array, if any parameter is null.

getValidSinkAtomsForMolecule

public static MolAtom[] getValidSinkAtomsForMolecule(Molecule m,
                                                     MolBond source)
Returns the atoms can be chosen as a sink for an electron flow with a MolBomd as a source in the molecule. Only the ending points of the bond can be chosen.

Parameters:
m - the molecule
source - the source of the electron flow in the molecule.
Returns:
the atoms in the molecule can be sink for this electron flow, or empty array, if any parameter is null.

getValidSourceBondsForMolecule

public static MolBond[] getValidSourceBondsForMolecule(Molecule m)
Returns the bonds can be chosen as a source for an electron flow in the molecule. All bonds in the Molecule can be selected as source.

Parameters:
m - the molecule
Returns:
the bonds in the molecule can be selected as source.

getValidSinkBondsForMolecule

public static MolBond[] getValidSinkBondsForMolecule(Molecule m,
                                                     MolAtom source)
Returns the bonds can be chosen as a sink for an electron flow with a MolAtom as a source in the molecule. The bonds connected to the atom can be sink.

Parameters:
m - the molecule
source - the source of the electron flow in the molecule.
Returns:
the bonds in the molecule can be sink for this electron flow, or empty array, if any parameter is null.

getValidSinkBondsForMolecule

public static MolBond[] getValidSinkBondsForMolecule(Molecule m,
                                                     MolBond source)
Returns the bonds can be chosen as a sink for an electron flow with a MolBond as a source in the molecule. The bonds connected to the endpoint atom can be sink (but not this bond).

Parameters:
m - the molecule
source - the source of the electron flow in the molecule.
Returns:
the bonds in the molecule can be sink for this electron flow, or empty array, if any parameter is null.

getValidSourceAtomPairsForMolecule

public static MolAtom[][] getValidSourceAtomPairsForMolecule(Molecule m)
Returns the atom pairs can be chosen as incipient bonds as a source for an electron flow in the molecule. Incipient bonds in the Molecule can not be selected as source.

Parameters:
m - the molecule
Returns:
an empty array.

getValidSinkAtomPairsForMolecule

public static MolAtom[][] getValidSinkAtomPairsForMolecule(Molecule m,
                                                           MolAtom source)
Returns the atom pairs can be chosen as a sink for an electron flow with a MolAtom as a source in the molecule. If the electron source is an atom A, then the electron sink can be an A-X incipient bond.

Parameters:
m - the molecule
source - the source of the electron flow in the molecule.
Returns:
the atom pairs in the molecule can be sink for this electron flow, or empty array, if any parameter is null.

getValidSinkAtomPairsForMolecule

public static MolAtom[][] getValidSinkAtomPairsForMolecule(Molecule m,
                                                           MolBond source)
Returns the atom pairs can be chosen as a sink for an electron flow with a MolBond as a source in the molecule. If the electron source is a bond A-B, then the electron sink can an A-X or B-X incipient bond.

Parameters:
m - the molecule
source - the source of the electron flow in the molecule.
Returns:
the atom pairs in the molecule can be sink for this electron flow, or empty array, if any parameter is null.

isValidSourceForMolecule

public static boolean isValidSourceForMolecule(java.lang.Object source,
                                               Molecule m)
Checks if the given Object can be a source of a electron flow in the molecule.

Parameters:
source - a MolAtom, a MolBond or a MolAtom[] array with length 1 or 2. If the length is 1 it represents a MolAtom, if 2 it represents a MolBond or an incipient bond between 2 atoms.
m - the molecule
Returns:
true if the source can be a source of an electron flow in the molecule, false otherwise.

isValidSourceAndSinkForMolecule

public static boolean isValidSourceAndSinkForMolecule(java.lang.Object source,
                                                      java.lang.Object sink,
                                                      Molecule m)
Checks if the given Objects can be a source and sink of a electron flow in the molecule.

Parameters:
source - a MolAtom, a MolBond or a MolAtom[] array with length 1 or 2. If the length is 1 it represents a MolAtom, if 2 it represents a MolBond or an incipient bond between 2 atoms.
sink - a MolAtom, a MolBond or a MolAtom[] array with length 1 or 2. If the length is 1 it represents a MolAtom, if 2 it represents a MolBond or an incipient bond between 2 atoms.
m - the molecule
Returns:
true if the objects can be source and sink of an electron flow in the molecule, false otherwise.

getSource

public java.lang.Object getSource()
Gets the origin of the electron-flow arrow (MolAtom or MolBond).

Returns:
origin of the electron-flow arrow

getSink

public java.lang.Object getSink()
Gets the destination of the electron-flow arrow (MolAtom, MolBond, or MolAtom[2] for incipient bond).

Returns:
destination of the electron-flow arrow

sourceIsAtom

public boolean sourceIsAtom()
Gets whether this arrow's source is an atom.

Returns:
whether this arrow's source is an atom

sinkIsAtom

public boolean sinkIsAtom()
Gets whether this arrow's sink is an atom.

Returns:
whether this arrow's sink is an atom

isAtom

public static boolean isAtom(java.lang.Object terminus)
Gets whether the arrow's terminus is at an atom.

Parameters:
terminus - the arrow terminus
Returns:
whether the arrow's terminus is at an atom

sourceIsBond

public boolean sourceIsBond()
Gets whether this arrow's source is a bond.

Returns:
whether this arrow's source is a bond

sinkIsBond

public boolean sinkIsBond()
Gets whether this arrow's sink is a bond.

Returns:
whether this arrow's sink is a bond

isBond

public static boolean isBond(java.lang.Object terminus)
Gets whether the arrow's terminus is at a bond.

Parameters:
terminus - the arrow terminus
Returns:
whether the arrow's terminus is at a bond

sinkIsIncipBond

public boolean sinkIsIncipBond()
Gets whether this arrow's sink is an incipient bond.

Returns:
whether this arrow's sink is an incipient bond

isIncipBond

public static boolean isIncipBond(java.lang.Object sink)
Gets whether the arrow's sink is at an incipient bond.

Parameters:
sink - the arrow sink
Returns:
whether the arrow's sink is at an incipient bond

getSourceAtom

public MolAtom getSourceAtom()
Gets the atom at the source of this arrow. Use only after sourceIsAtom().

Returns:
the atom at the source of this arrow

getSinkAtom

public MolAtom getSinkAtom()
Gets the atom at the sink of this arrow. Use only after sinkIsAtom().

Returns:
the atom at the sink of this arrow

getAtom

public static MolAtom getAtom(java.lang.Object terminus)
Gets the atom at the terminus of an arrow.

Parameters:
terminus - the arrow terminus
Returns:
the atom at the terminus of an arrow or null if it is not a MolAtom.

getBond

public static MolBond getBond(java.lang.Object terminus)
Gets the bond at the terminus of an arrow.

Parameters:
terminus - the arrow terminus
Returns:
the bond at the terminus of an arrow or null if the terminus is not a MolBond.

getSourceBond

public MolBond getSourceBond()
Gets the bond at the source of this arrow. Use only after sourceIsBond().

Returns:
the bond at the source of this arrow

getSinkBond

public MolBond getSinkBond()
Gets the bond at the sink of this arrow. Use only after sinkIsBond().

Returns:
the bond at the sink of this arrow

getSourceAtoms

public MolAtom[] getSourceAtoms()
Gets the atom or atoms at the arrow source.

Returns:
the atom or atoms at the arrow source

getSinkAtoms

public MolAtom[] getSinkAtoms()
Gets the atom or atoms at the arrow sink.

Returns:
the atom or atoms at the arrow sink

getAtoms

public static MolAtom[] getAtoms(java.lang.Object terminus)
Gets the atom or atoms at the terminus of an arrow.

Parameters:
terminus - the arrow terminus
Returns:
the atom or atoms at the terminus of an arrow