chemaxon.struc.sgroup
Class SuperatomSgroup

java.lang.Object
  extended bychemaxon.struc.Sgroup
      extended bychemaxon.struc.sgroup.SuperatomSgroup
All Implemented Interfaces:
Expandable, java.io.Serializable

public class SuperatomSgroup
extends Sgroup
implements Expandable

Superatom S-group.

Since:
Marvin 3.0, 11/05/2002
Version:
3.5.5, 03/08/2005
Author:
Peter Csizmadia
See Also:
Serialized Form

Field Summary
 
Fields inherited from class chemaxon.struc.Sgroup
SCN_EITHER_UNKNOWN, SCN_HEAD_TO_HEAD, SCN_HEAD_TO_TAIL, sgroupGraph, sgroupType, SORT_CHILD_PARENT, SORT_PARENT_CHILD, SST_ALTERNATING, SST_BLOCK, SST_RANDOM, ST_ANY, ST_COPOLYMER, ST_CROSSLINK, ST_DATA, ST_FORMULATION, ST_GENERIC, ST_MER, ST_MIXTURE, ST_MODIFICATION, ST_MONOMER, ST_MULTIPLE, ST_SRU, ST_SUPERATOM, XSTATE_C, XSTATE_NONE, XSTATE_X, XSTATE_XC
 
Fields inherited from interface chemaxon.struc.sgroup.Expandable
DEFAULT_OPTIONS, MDL_EXPAND, NONRECURSIVE_EXPAND, REVERSIBLE_EXPAND
 
Constructor Summary
  SuperatomSgroup(Molecule parent)
          Constructs a superatom S-group in expanded state.
  SuperatomSgroup(Molecule parent, boolean expanded)
          Constructs a superatom S-group.
protected SuperatomSgroup(SuperatomSgroup sg, Molecule m, Sgroup psg)
          Copy constructor.
 
Method Summary
protected  void addAttachAtom(MolAtom a)
          Adds an atom to the list of attachments.
 boolean areChildSgroupsVisible()
          Checks whether the child S-groups are visible.
 Sgroup cloneSgroup(Molecule m, Sgroup psg)
          Gets a new Sgroup instance.
 boolean contract(int opts)
          Contracts this S-group.
 Molecule createMolecule()
          Creates a molecule object that contains only this group.
 boolean expand(int opts)
          Expands this S-group.
 MolBond[] findCrossingBonds()
          Finds the crossing bonds.
 MolAtom getAttachAtom(int i)
          Gets an attachment point.
 MolAtom[] getCrossingAtoms(MolBond[] xbonds)
          Gets the atoms that have crossing bonds.
 MolAtom[] getFreeLegalAttachAtoms()
          Gets the unused legal attachment points.
 MolAtom[] getLegalAttachAtoms()
          Gets the legal attachment points.
 SelectionMolecule getSgroupGraph()
          Gets the molecule graph as a selection.
 SgroupAtom getSuperAtom()
          Gets the superatom.
 boolean hasAtom(MolAtom a)
          Is the specified atom an element of this group?
 boolean hasBrackets()
          Checks if brackets should be painted or not.
 boolean isBracketVisible()
          Tests whether the bracket is visible.
 boolean isContracted()
          Is this S-group contracted?
 boolean isExpanded()
          Is this S-group expanded?
 boolean isLegalAttachment(MolAtom a)
          Checks if the specified atom is attached to a legal attachment point.
 void removeAtom(MolAtom a)
          Removes an atom from the S-group.
 void removeBond(MolBond b)
          Removes a bond from the S-group.
 void replaceAtom(MolAtom olda, MolAtom newa)
          Replace an existing atom by a new one.
 void setAtom(int i, MolAtom a)
          Sets the specified atom in the S-group graph.
 void setSgroupGraph(SelectionMolecule smol)
          Sets the molecule graph.
 MolBond[] updateSgroupCrossings()
          Deprecated. as of Marvin 3.3, replaced by Sgroup.findCrossingBonds()
 
Methods inherited from class chemaxon.struc.Sgroup
add, addChildSgroup, cloneStructure, containsAllAtomsOf, countAllAtoms, findSmallestSgroupContaining, findSmallestSgroupOf, getAtom, getAtomArray, getAtomCount, getChildSgroup, getChildSgroupCount, getConnectivity, getParentMolecule, getParentSgroup, getSubscript, getSubType, getSuperscript, getType, getXState, indexOf, isEmpty, isVisible, removeEdges, removeGroupedAtom, setConnectivity, setGUIStateRecursively, setParentMolecule, setSubscript, setSubType, setXState, sort, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SuperatomSgroup

public SuperatomSgroup(Molecule parent)
Constructs a superatom S-group in expanded state.

Parameters:
parent - the parent molecule
Since:
Marvin 3.5.3, 01/18/2005

SuperatomSgroup

public SuperatomSgroup(Molecule parent,
                       boolean expanded)
Constructs a superatom S-group.

Parameters:
parent - the parent molecule
expanded - whether the S-group is created in expanded state or not

SuperatomSgroup

protected SuperatomSgroup(SuperatomSgroup sg,
                          Molecule m,
                          Sgroup psg)
Copy constructor.

Parameters:
sg - the S-group to copy
m - the new parent molecule
psg - the new parent S-group or null
Since:
Marvin 3.4
Method Detail

getSuperAtom

public final SgroupAtom getSuperAtom()
Gets the superatom.

Returns:
the superatom

getAttachAtom

public final MolAtom getAttachAtom(int i)
Gets an attachment point. This method should only be called when the residue is in contracted state.

Parameters:
i - the attachment point index
Returns:
the attachment atom

getSgroupGraph

public SelectionMolecule getSgroupGraph()
Gets the molecule graph as a selection. The nodes are ordered, the first n are the attachment atoms.

Overrides:
getSgroupGraph in class Sgroup
Returns:
the molecule graph
Since:
Marvin 3.3, 11/04/2003

setSgroupGraph

public void setSgroupGraph(SelectionMolecule smol)
Sets the molecule graph. The first n nodes are supposed to be the attachment points if the S-group is in contracted state.

Overrides:
setSgroupGraph in class Sgroup
Parameters:
smol - the molecule graph
Since:
Marvin 3.3, 11/04/2003

cloneSgroup

public Sgroup cloneSgroup(Molecule m,
                          Sgroup psg)
Gets a new Sgroup instance.

Overrides:
cloneSgroup in class Sgroup
Parameters:
m - the new parent molecule
psg - the new parent S-group
Returns:
the new object
Since:
Marvin 3.4

setAtom

public final void setAtom(int i,
                          MolAtom a)
Sets the specified atom in the S-group graph.

Overrides:
setAtom in class Sgroup
Parameters:
i - the index
a - the atom

removeAtom

public final void removeAtom(MolAtom a)
Removes an atom from the S-group.

Overrides:
removeAtom in class Sgroup
Parameters:
a - the atom

removeBond

public final void removeBond(MolBond b)
Removes a bond from the S-group.

Overrides:
removeBond in class Sgroup
Parameters:
b - the bond

findCrossingBonds

public MolBond[] findCrossingBonds()
Finds the crossing bonds. Use only when the S-group is expanded.

Overrides:
findCrossingBonds in class Sgroup
Returns:
the attachment bonds
Since:
Marvin 3.3

getCrossingAtoms

public MolAtom[] getCrossingAtoms(MolBond[] xbonds)
Gets the atoms that have crossing bonds.

Overrides:
getCrossingAtoms in class Sgroup
Parameters:
xbonds - the crossing bonds
Returns:
the attachment atoms
Since:
Marvin 3.3
See Also:
findCrossingBonds()

hasBrackets

public boolean hasBrackets()
Checks if brackets should be painted or not.

Overrides:
hasBrackets in class Sgroup
Returns:
true if the group is in expanded state
Since:
Marvin 3.3

hasAtom

public boolean hasAtom(MolAtom a)
Is the specified atom an element of this group?

Overrides:
hasAtom in class Sgroup
Parameters:
a - the atom
Returns:
true if it contains the atom, false otherwise
Since:
Marvin 3.4

expand

public final boolean expand(int opts)
                     throws java.lang.IllegalArgumentException
Expands this S-group. Atom indexes are preserved during expansion.

Specified by:
expand in interface Expandable
Overrides:
expand in class Sgroup
Parameters:
opts - expansion options
Returns:
true if the operation was successful, false if already expanded
Throws:
java.lang.IllegalArgumentException - if the group is invisible (it has a non-expanded parent)
See Also:
Sgroup.setXState(int)

isExpanded

public final boolean isExpanded()
Is this S-group expanded?

Specified by:
isExpanded in interface Expandable
Returns:
true if expanded, false if contracted

contract

public final boolean contract(int opts)
                       throws java.lang.IllegalArgumentException
Contracts this S-group.

Specified by:
contract in interface Expandable
Overrides:
contract in class Sgroup
Parameters:
opts - contraction options
Returns:
true if the operation was successful, false if already contracted
Throws:
java.lang.IllegalArgumentException - if the group is invisible (it has a non-expanded parent)
See Also:
Sgroup.setXState(int)

isContracted

public final boolean isContracted()
Is this S-group contracted?

Returns:
true if contracted, false if expanded

isBracketVisible

public boolean isBracketVisible()
Tests whether the bracket is visible.

Overrides:
isBracketVisible in class Sgroup
Returns:
false, superatom S-group brackets are not visible
Since:
Marvin 3.5.1, 11/12/2004

areChildSgroupsVisible

public boolean areChildSgroupsVisible()
Checks whether the child S-groups are visible.

Overrides:
areChildSgroupsVisible in class Sgroup
Returns:
true if children are visible, false otherwise
Since:
Marvin 3.4

getLegalAttachAtoms

public final MolAtom[] getLegalAttachAtoms()
Gets the legal attachment points.

Returns:
array of attachment points

isLegalAttachment

public final boolean isLegalAttachment(MolAtom a)
Checks if the specified atom is attached to a legal attachment point.

Returns:
true if it is attached to a legal attachment point, false otherwise
Since:
3.5, 11/04/2004

getFreeLegalAttachAtoms

public final MolAtom[] getFreeLegalAttachAtoms()
Gets the unused legal attachment points.

Returns:
array of attachment points

createMolecule

public Molecule createMolecule()
Creates a molecule object that contains only this group.

Overrides:
createMolecule in class Sgroup
Returns:
the molecule
Since:
Marvin 3.4

addAttachAtom

protected void addAttachAtom(MolAtom a)
Adds an atom to the list of attachments.

Parameters:
a - the atom

replaceAtom

public final void replaceAtom(MolAtom olda,
                              MolAtom newa)
Replace an existing atom by a new one.

Overrides:
replaceAtom in class Sgroup
Parameters:
olda - the original atom
newa - the new atom
Since:
3.5.2, 12/15/2004

updateSgroupCrossings

public final MolBond[] updateSgroupCrossings()
Deprecated. as of Marvin 3.3, replaced by Sgroup.findCrossingBonds()

Generates the attachment atoms. Use only when the S-group is expanded.

Returns:
the attachment bonds