Class: ChemStructureObjectGroup

ChemStructureObjectGroup

new ChemStructureObjectGroup(id)

A group of structure object. Each items in the group is in attrib=>obj form.
Parameters:
Name Type Description
id String Id of this group.
Properties:
Name Type Description
items Array Items in this group. Each item is a hash: {obj, amount, role...} where obj is the real ChemStructureObject and the rests are related attributes.
raiseExceptionOnTypeMismatch Bool Whether raise exception when wrong type of object is added to group.
Source:

Extends

Methods

appendChild(obj) → {Int}

Append obj to children list. If obj already inside, nothing will be done.
Parameters:
Name Type Description
obj Object
Source:
Returns:
Index of obj after appending.
Type
Int

appendItem(item)

Append an attrib-object pair item in group.
Parameters:
Name Type Description
item Hash
Source:

appendLinkedConnector(connector)

Link a connector to this node.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
Inherited From:
Source:

appendObj(obj, attributes)

Add object to group. If object already in group, nothing will be done.
Parameters:
Name Type Description
obj Kekule.ChemStructureObject
attributes Hash Additional attributes of this object. Can be null.
Source:

clearStructureFlags()

Clear all flags of structure object that should be changed when structure is changed. Descendants may override this method.
Inherited From:
Source:

compareStructure(targetObj, options) → {Int}

Explicit set compare method to chem structure and compare to targetObj.
Parameters:
Name Type Description
targetObj Kekule.ChemObject
options Hash
Inherited From:
Source:
Returns:
Type
Int

equalStructure(targetObj, options) → {Bool}

Check if this object and targetObj has equivalent chem structure.
Parameters:
Name Type Description
targetObj Kekule.ChemObject
options Hash
Inherited From:
Source:
Returns:
Type
Bool

getAllObjs() → {Array}

Returns an array containing the child objects (without attribute).
Source:
Returns:
Type
Array

getChildAt(index) → {Variant}

Get child object at index.
Parameters:
Name Type Description
index Int
Source:
Returns:
Type
Variant

getChildCount() → {Int}

Get count of child objects in root.
Source:
Returns:
Type
Int

getConnectorTo(obj) → {Kekule.ChemStructureConnector}

Get connector between this object and another object.
Parameters:
Name Type Description
obj Kekule.ChemStructureObject
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureConnector

getCurrConnectableObj() → {Kekule.ChemStructureObject}

Returns self or child object that can directly linked to a connector. For atom or other simple chem objetc, this function should just returns self, for structure fragment, this function need to returns an anchor node.
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureObject

getItemAt(index) → {Object}

Get item at index of items array.
Parameters:
Name Type Description
index Int
Source:
Returns:
Type
Object

getItemCount() → {Int}

Get count of items in group.
Source:
Returns:
Type
Int

getLinkedConnectorAt(index) → {Kekule.ChemStructureConnector}

Get linked connector object at index.
Parameters:
Name Type Description
index Int
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureConnector

getLinkedConnectorCount() → {Int}

Return count of linkedConnectors.
Inherited From:
Source:
Returns:
Type
Int

getLinkedHydrogenAtoms() → {Array}

Returns linked hydrogen atoms.
Inherited From:
Source:
Returns:
Type
Array

getLinkedNonHydrogenConnectors() → {Array}

Returns connectors that connected to a non hydrogen node.
Inherited From:
Source:
Returns:
Type
Array

getLinkedNonHydrogenObjs() → {Array}

Returns linked objects except hydrogen atoms.
Inherited From:
Source:
Returns:
Type
Array

getLinkedObjsOnConnector() → {Array}

Returns other objects connected to this one through connector.
Inherited From:
Source:
Returns:
Type
Array

getNextSiblingOfChild(child) → {Hash}

Returns next sibling item to child item or object.
Parameters:
Name Type Description
child Variant Item or object.
Source:
Returns:
Type
Hash

getObjAt(index) → {Object}

Get object stored in item at index.
Parameters:
Name Type Description
index Int
Source:
Returns:
Type
Object

getParentFragment() → {Kekule.StructureFragment}

If Kekule.ChemStructureObject#parent is a Kekule.StructureFragment, returns this fragment.
Inherited From:
Source:
Returns:
Type
Kekule.StructureFragment

getRootFragment() → {Kekule.StructureFragment}

Returns the root parent of Kekule.StructureFragment, rather than subgroups.
Inherited From:
Source:
Returns:
Type
Kekule.StructureFragment

hasObj(obj) → {Bool}

Check if obj exists in items.
Parameters:
Name Type Description
obj Object
Source:
Returns:
Type
Bool

indexOfChild(obj) → {Int}

Get the index of obj (object or object-attribute item) in children list of root.
Parameters:
Name Type Description
obj Variant
Source:
Returns:
Index of obj or -1 when not found.
Type
Int

indexOfItem(item) → {Int}

Get index of item in items array.
Parameters:
Name Type Description
item Object
Source:
Returns:
Index of item in array. If not found, returns -1.
Type
Int

indexOfLinkedConnector(connector) → {Int}

Returns index of connector connected to node.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
Inherited From:
Source:
Returns:
Type
Int

indexOfObj(obj) → {Int}

Get index of obj in items array.
Parameters:
Name Type Description
obj Object
Source:
Returns:
Index of object in array. If not found, returns -1.
Type
Int

insertBefore(item, refItem)

Insert attrib-object pair item before refChild in group. If refChild is null or does not exists, item will be append to tail of list.
Parameters:
Name Type Description
item Hash
refItem Hash
Source:

insertChild(obj, index) → {Int}

Insert obj to index of children list. If obj already inside, its position will be changed.
Parameters:
Name Type Description
obj Object
index Object
Source:
Returns:
Index of obj after inserting.
Type
Int

insertItem(item, index)

Insert an attrib-object pair item in group at index.
Parameters:
Name Type Description
item Hash
index Int
Source:

insertObj(item, index, attributes)

Insert an attrib-object pair item in group at index.
Parameters:
Name Type Description
item Hash
index Int
attributes Hash Additional attributes of this object. Can be null.
Source:

notifyItemsChanged()

Notify Kekule.ChemStructureObjectGroup#objs property has been changed
Source:

removeChild(obj)

Remove an object or attrib-object pair item from group.
Parameters:
Name Type Description
obj Variant
Source:

removeChildAt(index) → {Variant}

Remove a child at index.
Parameters:
Name Type Description
index Int
Source:
Returns:
Child object removed.
Type
Variant

removeItem(obj)

Remove an attrib-object pair item in group.
Parameters:
Name Type Description
obj Kekule.ChemStructureObject
Source:

removeItemAt(index)

Remove an attrib-object pair item at index in group.
Parameters:
Name Type Description
index Int
Source:

removeLinkedConnector(connector)

Remove a connector in linkedContainer.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
Inherited From:
Source:

removeLinkedConnectorAt(index)

Remove connector at index of linkedConnectors.
Parameters:
Name Type Description
index Int
Inherited From:
Source:

removeObj(obj)

Remove an object in group.
Parameters:
Name Type Description
obj Kekule.ChemStructureObject
Source:

removeObjAt(index)

Remove object at index in group.
Parameters:
Name Type Description
index Int
Source:

removeThisFromLinkedConnector()

Remove this node from all linked connectors. Ths method should be called before a object is removed from a structure.
Inherited From:
Source:

setAttributesAt(index, attributes)

Set additional fields of item at index.
Parameters:
Name Type Description
index Object
attributes Object
Source:

Events

structureChange

Invoked when object is changed and the change is related with structure (e.g. modify a bond, change a atomic number...). Event has field: {origin: the change source object (may be a child of event.target}.
Inherited From:
Source:

ChemStructureObjectGroup

new ChemStructureObjectGroup()

Source:

Methods

appendChild(obj) → {Int}

Append obj to children list. If obj already inside, nothing will be done.
Parameters:
Name Type Description
obj Object
Source:
Returns:
Index of obj after appending.
Type
Int

appendItem(item)

Append an attrib-object pair item in group.
Parameters:
Name Type Description
item Hash
Source:

appendLinkedConnector(connector)

Link a connector to this node.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
Inherited From:
Source:

appendObj(obj, attributes)

Add object to group. If object already in group, nothing will be done.
Parameters:
Name Type Description
obj Kekule.ChemStructureObject
attributes Hash Additional attributes of this object. Can be null.
Source:

clearStructureFlags()

Clear all flags of structure object that should be changed when structure is changed. Descendants may override this method.
Inherited From:
Source:

compareStructure(targetObj, options) → {Int}

Explicit set compare method to chem structure and compare to targetObj.
Parameters:
Name Type Description
targetObj Kekule.ChemObject
options Hash
Inherited From:
Source:
Returns:
Type
Int

equalStructure(targetObj, options) → {Bool}

Check if this object and targetObj has equivalent chem structure.
Parameters:
Name Type Description
targetObj Kekule.ChemObject
options Hash
Inherited From:
Source:
Returns:
Type
Bool

getAllObjs() → {Array}

Returns an array containing the child objects (without attribute).
Source:
Returns:
Type
Array

getChildAt(index) → {Variant}

Get child object at index.
Parameters:
Name Type Description
index Int
Source:
Returns:
Type
Variant

getChildCount() → {Int}

Get count of child objects in root.
Source:
Returns:
Type
Int

getConnectorTo(obj) → {Kekule.ChemStructureConnector}

Get connector between this object and another object.
Parameters:
Name Type Description
obj Kekule.ChemStructureObject
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureConnector

getCurrConnectableObj() → {Kekule.ChemStructureObject}

Returns self or child object that can directly linked to a connector. For atom or other simple chem objetc, this function should just returns self, for structure fragment, this function need to returns an anchor node.
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureObject

getItemAt(index) → {Object}

Get item at index of items array.
Parameters:
Name Type Description
index Int
Source:
Returns:
Type
Object

getItemCount() → {Int}

Get count of items in group.
Source:
Returns:
Type
Int

getLinkedConnectorAt(index) → {Kekule.ChemStructureConnector}

Get linked connector object at index.
Parameters:
Name Type Description
index Int
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureConnector

getLinkedConnectorCount() → {Int}

Return count of linkedConnectors.
Inherited From:
Source:
Returns:
Type
Int

getLinkedHydrogenAtoms() → {Array}

Returns linked hydrogen atoms.
Inherited From:
Source:
Returns:
Type
Array

getLinkedNonHydrogenConnectors() → {Array}

Returns connectors that connected to a non hydrogen node.
Inherited From:
Source:
Returns:
Type
Array

getLinkedNonHydrogenObjs() → {Array}

Returns linked objects except hydrogen atoms.
Inherited From:
Source:
Returns:
Type
Array

getLinkedObjsOnConnector() → {Array}

Returns other objects connected to this one through connector.
Inherited From:
Source:
Returns:
Type
Array

getNextSiblingOfChild(child) → {Hash}

Returns next sibling item to child item or object.
Parameters:
Name Type Description
child Variant Item or object.
Source:
Returns:
Type
Hash

getObjAt(index) → {Object}

Get object stored in item at index.
Parameters:
Name Type Description
index Int
Source:
Returns:
Type
Object

getParentFragment() → {Kekule.StructureFragment}

If Kekule.ChemStructureObject#parent is a Kekule.StructureFragment, returns this fragment.
Inherited From:
Source:
Returns:
Type
Kekule.StructureFragment

getRootFragment() → {Kekule.StructureFragment}

Returns the root parent of Kekule.StructureFragment, rather than subgroups.
Inherited From:
Source:
Returns:
Type
Kekule.StructureFragment

hasObj(obj) → {Bool}

Check if obj exists in items.
Parameters:
Name Type Description
obj Object
Source:
Returns:
Type
Bool

indexOfChild(obj) → {Int}

Get the index of obj (object or object-attribute item) in children list of root.
Parameters:
Name Type Description
obj Variant
Source:
Returns:
Index of obj or -1 when not found.
Type
Int

indexOfItem(item) → {Int}

Get index of item in items array.
Parameters:
Name Type Description
item Object
Source:
Returns:
Index of item in array. If not found, returns -1.
Type
Int

indexOfLinkedConnector(connector) → {Int}

Returns index of connector connected to node.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
Inherited From:
Source:
Returns:
Type
Int

indexOfObj(obj) → {Int}

Get index of obj in items array.
Parameters:
Name Type Description
obj Object
Source:
Returns:
Index of object in array. If not found, returns -1.
Type
Int

insertBefore(item, refItem)

Insert attrib-object pair item before refChild in group. If refChild is null or does not exists, item will be append to tail of list.
Parameters:
Name Type Description
item Hash
refItem Hash
Source:

insertChild(obj, index) → {Int}

Insert obj to index of children list. If obj already inside, its position will be changed.
Parameters:
Name Type Description
obj Object
index Object
Source:
Returns:
Index of obj after inserting.
Type
Int

insertItem(item, index)

Insert an attrib-object pair item in group at index.
Parameters:
Name Type Description
item Hash
index Int
Source:

insertObj(item, index, attributes)

Insert an attrib-object pair item in group at index.
Parameters:
Name Type Description
item Hash
index Int
attributes Hash Additional attributes of this object. Can be null.
Source:

notifyItemsChanged()

Notify Kekule.ChemStructureObjectGroup#objs property has been changed
Source:

removeChild(obj)

Remove an object or attrib-object pair item from group.
Parameters:
Name Type Description
obj Variant
Source:

removeChildAt(index) → {Variant}

Remove a child at index.
Parameters:
Name Type Description
index Int
Source:
Returns:
Child object removed.
Type
Variant

removeItem(obj)

Remove an attrib-object pair item in group.
Parameters:
Name Type Description
obj Kekule.ChemStructureObject
Source:

removeItemAt(index)

Remove an attrib-object pair item at index in group.
Parameters:
Name Type Description
index Int
Source:

removeLinkedConnector(connector)

Remove a connector in linkedContainer.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
Inherited From:
Source:

removeLinkedConnectorAt(index)

Remove connector at index of linkedConnectors.
Parameters:
Name Type Description
index Int
Inherited From:
Source:

removeObj(obj)

Remove an object in group.
Parameters:
Name Type Description
obj Kekule.ChemStructureObject
Source:

removeObjAt(index)

Remove object at index in group.
Parameters:
Name Type Description
index Int
Source:

removeThisFromLinkedConnector()

Remove this node from all linked connectors. Ths method should be called before a object is removed from a structure.
Inherited From:
Source:

setAttributesAt(index, attributes)

Set additional fields of item at index.
Parameters:
Name Type Description
index Object
attributes Object
Source:

Events

structureChange

Invoked when object is changed and the change is related with structure (e.g. modify a bond, change a atomic number...). Event has field: {origin: the change source object (may be a child of event.target}.
Inherited From:
Source: