recommended new MEFlow methods

User 870ab5b546

20-09-2011 13:05:42

In this post, I recommended that you add several new methods to MEFlow that would be useful to programmers.  You still haven't done so.  I still recommend that you do.


/** Gets the origin of the electron-flow arrow (MolAtom, MolBond, or 
* MEFlowBasePoint).
* @return origin of the electron-flow arrow
*/
public Object getSource() { return getMolObject(E_SOURCE); }

/** Gets the destination of the electron-flow arrow (MolAtom, MolBond, or
* MolAtom[2] for incipient bond).
* @return destination of the electron-flow arrow
*/
public Object getSink() { return getMolObject(E_SINK); }

/** Gets whether this arrow's source is an atom.
* @return whether this arrow's source is an atom
*/
public boolean sourceIsAtom() {
return isAtom(getSource());
} // sourceIsAtom()

/** Gets whether this arrow's sink is an atom.
* @return whether this arrow's sink is an atom
*/
public boolean sinkIsAtom() {
return isAtom(getSink());
} // sinkIsAtom()

/** Gets whether the arrow's terminus is at an atom.
* @param terminus the arrow terminus
* @return whether the arrow's terminus is at an atom
*/
public static boolean isAtom(Object terminus) {
return (terminus instanceof MolAtom
|| terminus instanceof MEFlowBasePoint);
} // isAtom(Object)

/** Gets whether this arrow's source is a bond.
* @return whether this arrow's source is a bond
*/
public boolean sourceIsBond() {
return isBond(getSource());
} // sourceIsBond()

/** Gets whether this arrow's sink is a bond.
* @return whether this arrow's sink is a bond
*/
public boolean sinkIsBond() {
return isBond(getSink());
} // sinkIsBond()

/** Gets whether the arrow's terminus is at a bond.
* @param terminus the arrow terminus
* @return whether the arrow's terminus is at a bond
*/
public static boolean isBond(Object terminus) {
return (terminus instanceof MolBond);
} // isBond(Object)

/** Gets whether this arrow's sink is an incipient bond.
* @return whether this arrow's sink is an incipient bond
*/
public boolean sinkIsIncipBond() {
return isIncipBond(getSink());
} // sinkIsIncipBond()

/** Gets whether the arrow's sink is at an incipient bond.
* @param sink the arrow sink
* @return whether the arrow's sink is at an incipient bond
*/
public static boolean isIncipBond(Object sink) {
return (sink instanceof MolAtom[]);
} // isIncipBond(Object)

/** Gets the atom at the source of this arrow. Use only after sourceIsAtom().
* @return the atom at the source of this arrow
*/
public MolAtom getSourceAtom() {
return getAtom(getSource());
} // getSourceAtom()

/** Gets the atom at the sink of this arrow. Use only after sinkIsAtom().
* @return the atom at the sink of this arrow
*/
public MolAtom getSinkAtom() {
return getAtom(getSink());
} // getSinkAtom()

/** Gets the atom at the terminus of an arrow.
* @param terminus the arrow terminus
* @return the atom at the terminus of an arrow
*/
public static MolAtom getAtom(Object terminus) {
public MolAtom atom;
if (terminus instanceof MolAtom) {
atom = (MolAtom) terminus;
} else if (terminus instanceof MEFlowBasePoint) {
atom = ((MEFlowBasePoint) terminus).getAtom();
} else {
atom = null;
}
return atom;
} // getAtom(Object)

/** Gets the bond at the terminus of an arrow.
* @param terminus the arrow terminus
* @return the bond at the terminus of an arrow
*/
public static MolBond getBond(Object terminus) {
return ((MolBond) terminus);
} // getBond(Object)

/** Gets the bond at the source of this arrow. Use only after sourceIsBond().
* @return the bond at the source of this arrow
*/
public MolBond getSourceBond() {
return getBond(getSource());
} // getSourceBond()

/** Gets the bond at the sink of this arrow. Use only after sinkIsBond().
* @return the bond at the sink of this arrow
*/
public MolBond getSinkBond() {
return getBond(getSink());
} // getSinkBond()

/** Gets the atom or atoms at the arrow source.
* @return the atom or atoms at the arrow source
*/
public MolAtom[] getSourceAtoms() {
return getAtoms(getSource());
} // getSourceAtoms()

/** Gets the atom or atoms at the arrow sink.
* @return the atom or atoms at the arrow sink
*/
public MolAtom[] getSinkAtoms() {
return getAtoms(getSink());
} // getSinkAtoms()

/** Gets the atom or atoms at the terminus of an arrow.
* @param terminus the arrow terminus
* @return the atom or atoms at the terminus of an arrow
*/
public static MolAtom[] getAtoms(Object terminus) {
public MolAtom[] atoms;
if (isAtom(terminus)) {
atoms = new MolAtom[] {getAtom(terminus)};
} else if (isBond(terminus)) {
MolBond bond = (MolBond) terminus;
atoms = new MolAtom[] {bond.getAtom1(), bond.getAtom2()};
} else if (isIncipBond(terminus)) {
atoms = (MolAtom[]) terminus;
} else {
atoms = new MolAtom[0];
}
return atoms;
} // getAtoms(Object)

ChemAxon 0a9e2a55e1

21-09-2011 09:11:17

I have told these requests to the project manager, he will decide when these functions can be added.