Class: ChemObjPainter2D

Kekule.Render. ChemObjPainter2D

new ChemObjPainter2D(chemObj, drawBridge, options, renderConfigs)

Painter used by user to draw a chem object in 2D.
Parameters:
Name Type Description
chemObj Kekule.ChemObject Object to be drawn.
drawBridge Object A object that implements the actual draw job.
options Hash Options to draw object.
renderConfigs Object Global configuration for rendering. This property should be an instance of Kekule.Render.Render2DConfigs or Kekule.Render.Render3DConfigs. Set this param to null to use default configs.
Source:

Extends

Methods

addEventListener(eventName, listener, thisArg) → {Object}

Add an event handler.
Parameters:
Name Type Description
eventName String Name of event.
listener function Handler function.
thisArg Object The scope object applied when the handler is called.
Inherited From:
Source:
Returns:
Handler info object on success, null on fail.
Type
Object

addOnceEventListener(eventName, listener, thisArg) → {Object}

Add an event handler that will only be evoked once.
Parameters:
Name Type Description
eventName String Name of event.
listener function Handler function.
thisArg Object The scope object applied when the handler is called.
Inherited From:
Source:
Returns:
Handler info object on success, null on fail.
Type
Object

afterInitialization()

Do jobs after initialization, desendants can override this method
Inherited From:
Source:

assign(srcObj)

Assign data in srcObj to this object.
Parameters:
Name Type Description
srcObj ObjectEx
Inherited From:
Source:

assignTo(targetObj)

Assign data in this object to targetObj.
Parameters:
Name Type Description
targetObj ObjectEx
Inherited From:
Source:

beginUpdate()

Begin to update multiple properties of object. In update state, all changed properties will not invoke propertySet event until method endUpdate is called.
Inherited From:
Source:

beginUpdatePainter()

Call this method before a series of rendered element updating job (for instance, call update method) to avoid unnecessary redraw.
Inherited From:
Source:

changeGeometryOptions(context, newOptions)

Repaint with only geometry options (translate/zoom/rotate) changes (without the modification of chemobj or draw color, molecule type...). In 3D mode sometimes this repainting can be achieved by the modify of camera position (without recalc the position of node and connectors) so that the speed may enhance greatly.
Parameters:
Name Type Description
context Object
newOptions Hash
Inherited From:
Source:

clear(context) → {Bool}

Clear whole chemObj on context.
Parameters:
Name Type Description
context Object
Inherited From:
Source:
Returns:
Whether the actual clear job is done.
Type
Bool

clearContext(context)

Clear the painted objects in whole context.
Parameters:
Name Type Description
context Object
Inherited From:
Source:

clone() → {ObjectEx}

Returns a cloned object.
Inherited From:
Source:
Returns:
Type
ObjectEx

copyPropsTo(dest)

Copy property values to dest object. Dest must be a desendant of ObjectEx.
Parameters:
Name Type Description
dest ObjectEx
Inherited From:
Source:

createContext(parentElem, width, height) → {Object}

Create an suitable context for drawing.
Parameters:
Name Type Description
parentElem Element HTML element, context will be append to it.
width Int
height Int
Inherited From:
Source:
Returns:
Type
Object

defineEvent(eventName) → {Object}

Define an event in class. Event is actually a special property with type Class.EventHandlerList
Parameters:
Name Type Description
eventName String Name of event.
Inherited From:
Deprecated:
  • Yes
Source:
Returns:
Property info object created.
Type
Object

defineProp(propName, options) → {Object}

Define a property in class.
Parameters:
Name Type Description
propName String Name of property, case sensitive.
options Object A hash object, may contains the following fields: { dataType: type of property data, a string constant in DataType or a class name. //storeField: field in object to store property value, // not allowed for running speed getter: getter function, setter: setter function, if set to null, the property will be read-only, serializable: boolean, whether the property should be save or restore in serialization. Default is true. defaultValue: default value of property, can only be simple type (number, string, bool...) }
Inherited From:
Source:
Returns:
Property info object added to property list.
Type
Object

doEndUpdate()

Actual work of endUpdate, just invoke all property change events.
Inherited From:
Source:

doPropChanged(propName, newValue)

Do some job when a property value is changed. Descendants can override this.
Parameters:
Name Type Description
propName String Name of property.
newValue Variant New value of the property.
Inherited From:
Source:

draw(context, baseCoord, options)

Draw an instance of ChemObject to context. The actual job is done in doDraw method. Descendants should override doDraw.
Parameters:
Name Type Description
context Object Context to be drawn, such as Canvas, SVG, VML and so on.
baseCoord Hash Coord of center to draw this object, can be null. This coord is based on context.
options Hash Draw options, such as draw rectangle, draw style, zoom and so on. Different coordMode may requires different option params.
Inherited From:
Source:

endUpdate()

Update end and notify all properties changed after calling of beginUpdate.
Inherited From:
Source:

endUpdatePainter()

Call this method after a series of rendered element updateing job, notify the painter to redraw the context.
Inherited From:
Source:

estimateObjBox(context, options, allowCoordBorrow) → {Hash}

Estimate the bound box around current chemObj (in chem coord system).
Parameters:
Name Type Description
context Object
options Object
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
A 2D or 3D box, in chemObj's coord system.
Type
Hash

estimateRenderBox(context, baseCoord, options, allowCoordBorrow) → {Hash}

Estimate the bound box need to render current chemObj (in context coord system).
Parameters:
Name Type Description
context Object
baseCoord Hash Center coord in context to draw object. Can be null.
options Object
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
A 2D or 3D box, in context's coord system.
Type
Hash

estimateScreenBox(context, baseCoord, options, allowCoordBorrow) → {Hash}

Estimate the bound box need to render current chemObj (in screen coord system).
Parameters:
Name Type Description
context Object
baseCoord Hash Center coord in context to draw object. Can be null.
options Object
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
A 2D or 3D box, in context's coord system.
Type
Hash

finalize()

Free resources used. Like finalize method in Java.
Inherited From:
Source:

getAllPropList() → {Class.PropList}

Get list of all properties in this class, including ones inherited from parent class.
Inherited From:
Source:
Returns:
Type
Class.PropList

getClass() → {Object}

Get class of this object.
Inherited From:
Source:
Returns:
Class object.
Type
Object

getClassLocalName() → {String}

Get last part of class name of this object. For example, 'Atom' will be returned by instance of class 'Kekule.Atom'.
Inherited From:
Source:
Returns:
Last part of class name of object.
Type
String

getClassName() → {String}

Get class name of this object, usually returns CLASS_NAME field.
Inherited From:
Source:
Returns:
Class name of object.
Type
String

getEventHandlerList(eventName) → {Class.EventHandlerList}

Get the handler list of a event.
Parameters:
Name Type Description
eventName String Name of event.
Inherited From:
Source:
Returns:
Handler list of event. If this event does not exist, null is returned.
Type
Class.EventHandlerList

getOwnPropList() → {Class.PropList}

Get property list of this class. The properties inherited from parent class will not be returned.
Inherited From:
Source:
Returns:
Type
Class.PropList

getPropertyDataType(propName) → {String}

Returns type constants of property.
Parameters:
Name Type Description
propName String
Inherited From:
Source:
Returns:
Values from DataType.
Type
String

getPropInfo(propName, ownPropertyOnly) → {Object}

Get property info object from the property list of current class.
Parameters:
Name Type Description
propName String Name of property.
ownPropertyOnly Bool If true, only property defined in this class will be checked.
Inherited From:
Source:
Returns:
Property info object found. If there is no such a property, null is returned.
Type
Object

getPropListOfScopes(scopes) → {Class.PropList}

Get list of all properties of certain scopes in this class, including ones inherited from parent class.
Parameters:
Name Type Description
scopes Array Array item from Class.PropertyScope.
Inherited From:
Source:
Returns:
Type
Class.PropList

getPropStoreFieldValue(propName) → {Variant}

Get value of a property's store field. Use this method to get property value and avoid the call of property getter. Note: if the property has no store field, this method may returns null or undefined.
Parameters:
Name Type Description
propName String Name of property.
Inherited From:
Source:
Returns:
Value of property. If property does not exists, null is returned.
Type
Variant

getPropValue(propName) → {Variant}

Get value of a property.
Parameters:
Name Type Description
propName String Name of property.
Inherited From:
Source:
Returns:
Value of property. If property does not exists, null is returned.
Type
Variant

getPropValues(propNames) → {Hash}

Returns values of a series of properties.
Parameters:
Name Type Description
propNames Variant Can be an array of property names, also can be an object while the direct field names of object will be regarded as property names.
Inherited From:
Source:
Returns:
Stores all property name-value pair.
Type
Hash

getPrototype() → {Object}

Get prototype of this object.
Inherited From:
Source:
Returns:
Type
Object

getSerializationName() → {String}

Returns a name to be used in serialization. Descendants can override this.
Inherited From:
Source:
Returns:
Type
String

getSuperClass() → {Object}

Get super class of this object.
Inherited From:
Source:
Returns:
Class object.
Type
Object

getSuperClassPrototype() → {Object}

Get prototype of super class.
Inherited From:
Source:
Returns:
If there is no super class, null is returned.
Type
Object

hasDirectProperty(propName) → {Boolean}

Check if property is defined in current class (not inherited from super class).
Parameters:
Name Type Description
propName String Name of property.
Inherited From:
Source:
Returns:
Type
Boolean

hasProperty(propName) → {Boolean}

Check if property exists in current class.
Parameters:
Name Type Description
propName String Name of property.
Inherited From:
Source:
Returns:
Type
Boolean

initPropValues()

Set initial value of properties. Desendants can override this method.
Inherited From:
Source:

invokeEvent(eventName, event)

Invoke an event and call all corresponding handlers (listeners).
Parameters:
Name Type Description
eventName String Event to be invoked.
event Object A hash object with information about event. At least should include the following fields: { name: name of event, target: which object invoke this event, generally this object } If this parameter is not set, the default value {eventName, this} will be used.
Inherited From:
Source:

isEventHandlerList(value) → {bool}

Check if a object is Class.EventHandlerList.
Parameters:
Name Type Description
value Object
Inherited From:
Source:
Returns:
True or false.
Type
bool

isPropertySerializable(propName) → {Bool}

Returns if property is serializable.
Parameters:
Name Type Description
propName String
Inherited From:
Source:
Returns:
Type
Bool

isPropUpdated(propName)

Check whether property is changed in begin/endUpdate procedure.
Parameters:
Name Type Description
propName Object
Inherited From:
Source:

isUpdating()

Check if object is in updating state.
Inherited From:
Source:

loaded()

Called after this object is loaded by a serialization system. Descendants may override this.
Inherited From:
Source:

loadObj(srcNode, serializerOrName)

load current object from srcNode.
Parameters:
Name Type Description
srcNode Object Storage node to load object. Different serializer requires different node.
serializerOrName Variant A ObjSerializer instance or name registered in ObjSerializerFactory. Can be null to use the default serializer.
Inherited From:
Source:

notifyPropSet(propName, newValue)

Notify that a property value is set
Parameters:
Name Type Description
propName String Name of property.
newValue Variant New value of the property.
Inherited From:
Source:

objectChange()

Called when object is changed.
Inherited From:
Source:

off(eventName, listener, thisArg)

Remove an event handler, shortcut for (@link ObjectEx.removeEventListener}.
Parameters:
Name Type Description
eventName String Name of event.
listener function Handler function.
thisArg Object The scope object applied when the handler is called. If not set, all listenr function in list will be removed.
Inherited From:
Source:

on(eventName, listener, thisArg) → {Object}

Add an event handler, shortcut for ObjectEx.addEventListener.
Parameters:
Name Type Description
eventName String Name of event.
listener function Handler function.
thisArg Object The scope object applied when the handler is called.
Inherited From:
Source:
Returns:
Handler info object on success, null on fail.
Type
Object

once(eventName, listener, thisArg) → {Object}

Add an event handler that will only be evoked once, shortcut for ObjectEx.addOnceEventListener.
Parameters:
Name Type Description
eventName String Name of event.
listener function Handler function.
thisArg Object The scope object applied when the handler is called.
Inherited From:
Source:
Returns:
Handler info object on success, null on fail.
Type
Object

overwriteMethod(methodName, newMethod) → {ObjectEx}

Overwrite method of object instance (rather than prototype) with a new one.
Parameters:
Name Type Description
methodName String
newMethod Func New function. The arguments of function should be same as overwritten one plus a extra leading param stores the old method. e.g. Overwrite getPropValue method:
var obj = new ObjectEx();
obj.overwriteMethod('getPropValue', function($old, propName)
{
console.log('new method'); return $old(propName); });
Inherited From:
Source:
Returns:
Type
ObjectEx

redraw(context)

Redraw previous object on context with same draw options. Should not be called before draw.
Parameters:
Name Type Description
context Object
Inherited From:
Source:

relayEvent(eventName, event)

Relay event from child of this object.
Parameters:
Name Type Description
eventName String Event to be invoked.
event Object A hash object with information about event.
Inherited From:
Source:

removeEventListener(eventName, listener, thisArg)

Remove an event handler.
Parameters:
Name Type Description
eventName String Name of event.
listener function Handler function.
thisArg Object The scope object applied when the handler is called. If not set, all listenr function in list will be removed.
Inherited From:
Source:

saved()

Called after this object is saved through a serialization system. Descendants may override this.
Inherited From:
Source:

saveObj(destNode, serializerOrName, options)

Save current object to destNode.
Parameters:
Name Type Description
destNode Object Storage node to save object. Different serializer requires different node.
serializerOrName Variant A ObjSerializer instance or name registered in ObjSerializerFactory. Can be null to use the default serializer.
options Hash
Inherited From:
Source:

setPropStoreFieldValue(propName) → {Variant}

Set value of a property's store field. Use this method to set property value and avoid the call of property setter. Readonly property can also be changed in this method. Note: if the property has no store field, this method will has no effect on property.
Parameters:
Name Type Description
propName String Name of property.
Inherited From:
Source:
Returns:
Value of property. If property does not exists, null is returned.
Type
Variant

setPropValue(propName, value, ignoreReadOnly)

Set value of a property.
Parameters:
Name Type Description
propName String Name of property.
value Variant Value of the property.
ignoreReadOnly bool Try set the value directly through store field even if the property is a readonly one (without a setter).
Inherited From:
Source:

setPropValues(hash, ignoreReadOnly)

Set a series of property.
Parameters:
Name Type Description
hash Hash A hash object, its key and values will be used to set property value.
ignoreReadOnly bool Try set the value directly through store field even if the property is a readonly one (without a setter).
Inherited From:
Source:

setPropValueX()

Set value of a property. Similar to ObjectEx.setPropValue but can pass in multiple params. The first param is always the property name while the rest will be put into setter method (setXXX).
Inherited From:
Source:

stopEventPropagation(event)

Stop propagation of event, disallow it to bubble to higher level.
Parameters:
Name Type Description
event Object
Inherited From:
Source:

supportGeometryOptionChange() → {Bool}

Check if changeGeometryOptions is availble to current renderer.
Inherited From:
Source:
Returns:
Type
Bool

update(context, updatedObjs, updateType)

Update a child object inside chemObj. Must be called after draw.
Parameters:
Name Type Description
context Object
updatedObjs Variant Object or Array
updateType Int Value from Kekule.Render.ObjectUpdateType
Inherited From:
Source:

Events

change

Invoked when the object has been modified. event param of it has one fields: {changedPropNames: Array}
Inherited From:
Source:

finalize

Invoked when ObjectEx#finalize is called and the object is released. event param of it has one fields: {obj}
Inherited From:
Source:

propValueSet

Invoked when a property value is set by its setter event param of it has two fields: {propName, propValue} If property enablePropValueSetEvent is false, this event will never be fired.
Inherited From:
Source:

Kekule.Render. ChemObjPainter2D

new ChemObjPainter2D()

Source:

Methods

addEventListener(eventName, listener, thisArg) → {Object}

Add an event handler.
Parameters:
Name Type Description
eventName String Name of event.
listener function Handler function.
thisArg Object The scope object applied when the handler is called.
Inherited From:
Source:
Returns:
Handler info object on success, null on fail.
Type
Object

addOnceEventListener(eventName, listener, thisArg) → {Object}

Add an event handler that will only be evoked once.
Parameters:
Name Type Description
eventName String Name of event.
listener function Handler function.
thisArg Object The scope object applied when the handler is called.
Inherited From:
Source:
Returns:
Handler info object on success, null on fail.
Type
Object

afterInitialization()

Do jobs after initialization, desendants can override this method
Inherited From:
Source:

assign(srcObj)

Assign data in srcObj to this object.
Parameters:
Name Type Description
srcObj ObjectEx
Inherited From:
Source:

assignTo(targetObj)

Assign data in this object to targetObj.
Parameters:
Name Type Description
targetObj ObjectEx
Inherited From:
Source:

beginUpdate()

Begin to update multiple properties of object. In update state, all changed properties will not invoke propertySet event until method endUpdate is called.
Inherited From:
Source:

beginUpdatePainter()

Call this method before a series of rendered element updating job (for instance, call update method) to avoid unnecessary redraw.
Inherited From:
Source:

changeGeometryOptions(context, newOptions)

Repaint with only geometry options (translate/zoom/rotate) changes (without the modification of chemobj or draw color, molecule type...). In 3D mode sometimes this repainting can be achieved by the modify of camera position (without recalc the position of node and connectors) so that the speed may enhance greatly.
Parameters:
Name Type Description
context Object
newOptions Hash
Inherited From:
Source:

clear(context) → {Bool}

Clear whole chemObj on context.
Parameters:
Name Type Description
context Object
Inherited From:
Source:
Returns:
Whether the actual clear job is done.
Type
Bool

clearContext(context)

Clear the painted objects in whole context.
Parameters:
Name Type Description
context Object
Inherited From:
Source:

clone() → {ObjectEx}

Returns a cloned object.
Inherited From:
Source:
Returns:
Type
ObjectEx

copyPropsTo(dest)

Copy property values to dest object. Dest must be a desendant of ObjectEx.
Parameters:
Name Type Description
dest ObjectEx
Inherited From:
Source:

createContext(parentElem, width, height) → {Object}

Create an suitable context for drawing.
Parameters:
Name Type Description
parentElem Element HTML element, context will be append to it.
width Int
height Int
Inherited From:
Source:
Returns:
Type
Object

defineEvent(eventName) → {Object}

Define an event in class. Event is actually a special property with type Class.EventHandlerList
Parameters:
Name Type Description
eventName String Name of event.
Inherited From:
Deprecated:
  • Yes
Source:
Returns:
Property info object created.
Type
Object

defineProp(propName, options) → {Object}

Define a property in class.
Parameters:
Name Type Description
propName String Name of property, case sensitive.
options Object A hash object, may contains the following fields: { dataType: type of property data, a string constant in DataType or a class name. //storeField: field in object to store property value, // not allowed for running speed getter: getter function, setter: setter function, if set to null, the property will be read-only, serializable: boolean, whether the property should be save or restore in serialization. Default is true. defaultValue: default value of property, can only be simple type (number, string, bool...) }
Inherited From:
Source:
Returns:
Property info object added to property list.
Type
Object

doEndUpdate()

Actual work of endUpdate, just invoke all property change events.
Inherited From:
Source:

doPropChanged(propName, newValue)

Do some job when a property value is changed. Descendants can override this.
Parameters:
Name Type Description
propName String Name of property.
newValue Variant New value of the property.
Inherited From:
Source:

draw(context, baseCoord, options)

Draw an instance of ChemObject to context. The actual job is done in doDraw method. Descendants should override doDraw.
Parameters:
Name Type Description
context Object Context to be drawn, such as Canvas, SVG, VML and so on.
baseCoord Hash Coord of center to draw this object, can be null. This coord is based on context.
options Hash Draw options, such as draw rectangle, draw style, zoom and so on. Different coordMode may requires different option params.
Inherited From:
Source:

endUpdate()

Update end and notify all properties changed after calling of beginUpdate.
Inherited From:
Source:

endUpdatePainter()

Call this method after a series of rendered element updateing job, notify the painter to redraw the context.
Inherited From:
Source:

estimateObjBox(context, options, allowCoordBorrow) → {Hash}

Estimate the bound box around current chemObj (in chem coord system).
Parameters:
Name Type Description
context Object
options Object
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
A 2D or 3D box, in chemObj's coord system.
Type
Hash

estimateRenderBox(context, baseCoord, options, allowCoordBorrow) → {Hash}

Estimate the bound box need to render current chemObj (in context coord system).
Parameters:
Name Type Description
context Object
baseCoord Hash Center coord in context to draw object. Can be null.
options Object
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
A 2D or 3D box, in context's coord system.
Type
Hash

estimateScreenBox(context, baseCoord, options, allowCoordBorrow) → {Hash}

Estimate the bound box need to render current chemObj (in screen coord system).
Parameters:
Name Type Description
context Object
baseCoord Hash Center coord in context to draw object. Can be null.
options Object
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
A 2D or 3D box, in context's coord system.
Type
Hash

finalize()

Free resources used. Like finalize method in Java.
Inherited From:
Source:

getAllPropList() → {Class.PropList}

Get list of all properties in this class, including ones inherited from parent class.
Inherited From:
Source:
Returns:
Type
Class.PropList

getClass() → {Object}

Get class of this object.
Inherited From:
Source:
Returns:
Class object.
Type
Object

getClassLocalName() → {String}

Get last part of class name of this object. For example, 'Atom' will be returned by instance of class 'Kekule.Atom'.
Inherited From:
Source:
Returns:
Last part of class name of object.
Type
String

getClassName() → {String}

Get class name of this object, usually returns CLASS_NAME field.
Inherited From:
Source:
Returns:
Class name of object.
Type
String

getEventHandlerList(eventName) → {Class.EventHandlerList}

Get the handler list of a event.
Parameters:
Name Type Description
eventName String Name of event.
Inherited From:
Source:
Returns:
Handler list of event. If this event does not exist, null is returned.
Type
Class.EventHandlerList

getOwnPropList() → {Class.PropList}

Get property list of this class. The properties inherited from parent class will not be returned.
Inherited From:
Source:
Returns:
Type
Class.PropList

getPropertyDataType(propName) → {String}

Returns type constants of property.
Parameters:
Name Type Description
propName String
Inherited From:
Source:
Returns:
Values from DataType.
Type
String

getPropInfo(propName, ownPropertyOnly) → {Object}

Get property info object from the property list of current class.
Parameters:
Name Type Description
propName String Name of property.
ownPropertyOnly Bool If true, only property defined in this class will be checked.
Inherited From:
Source:
Returns:
Property info object found. If there is no such a property, null is returned.
Type
Object

getPropListOfScopes(scopes) → {Class.PropList}

Get list of all properties of certain scopes in this class, including ones inherited from parent class.
Parameters:
Name Type Description
scopes Array Array item from Class.PropertyScope.
Inherited From:
Source:
Returns:
Type
Class.PropList

getPropStoreFieldValue(propName) → {Variant}

Get value of a property's store field. Use this method to get property value and avoid the call of property getter. Note: if the property has no store field, this method may returns null or undefined.
Parameters:
Name Type Description
propName String Name of property.
Inherited From:
Source:
Returns:
Value of property. If property does not exists, null is returned.
Type
Variant

getPropValue(propName) → {Variant}

Get value of a property.
Parameters:
Name Type Description
propName String Name of property.
Inherited From:
Source:
Returns:
Value of property. If property does not exists, null is returned.
Type
Variant

getPropValues(propNames) → {Hash}

Returns values of a series of properties.
Parameters:
Name Type Description
propNames Variant Can be an array of property names, also can be an object while the direct field names of object will be regarded as property names.
Inherited From:
Source:
Returns:
Stores all property name-value pair.
Type
Hash

getPrototype() → {Object}

Get prototype of this object.
Inherited From:
Source:
Returns:
Type
Object

getSerializationName() → {String}

Returns a name to be used in serialization. Descendants can override this.
Inherited From:
Source:
Returns:
Type
String

getSuperClass() → {Object}

Get super class of this object.
Inherited From:
Source:
Returns:
Class object.
Type
Object

getSuperClassPrototype() → {Object}

Get prototype of super class.
Inherited From:
Source:
Returns:
If there is no super class, null is returned.
Type
Object

hasDirectProperty(propName) → {Boolean}

Check if property is defined in current class (not inherited from super class).
Parameters:
Name Type Description
propName String Name of property.
Inherited From:
Source:
Returns:
Type
Boolean

hasProperty(propName) → {Boolean}

Check if property exists in current class.
Parameters:
Name Type Description
propName String Name of property.
Inherited From:
Source:
Returns:
Type
Boolean

initPropValues()

Set initial value of properties. Desendants can override this method.
Inherited From:
Source:

invokeEvent(eventName, event)

Invoke an event and call all corresponding handlers (listeners).
Parameters:
Name Type Description
eventName String Event to be invoked.
event Object A hash object with information about event. At least should include the following fields: { name: name of event, target: which object invoke this event, generally this object } If this parameter is not set, the default value {eventName, this} will be used.
Inherited From:
Source:

isEventHandlerList(value) → {bool}

Check if a object is Class.EventHandlerList.
Parameters:
Name Type Description
value Object
Inherited From:
Source:
Returns:
True or false.
Type
bool

isPropertySerializable(propName) → {Bool}

Returns if property is serializable.
Parameters:
Name Type Description
propName String
Inherited From:
Source:
Returns:
Type
Bool

isPropUpdated(propName)

Check whether property is changed in begin/endUpdate procedure.
Parameters:
Name Type Description
propName Object
Inherited From:
Source:

isUpdating()

Check if object is in updating state.
Inherited From:
Source:

loaded()

Called after this object is loaded by a serialization system. Descendants may override this.
Inherited From:
Source:

loadObj(srcNode, serializerOrName)

load current object from srcNode.
Parameters:
Name Type Description
srcNode Object Storage node to load object. Different serializer requires different node.
serializerOrName Variant A ObjSerializer instance or name registered in ObjSerializerFactory. Can be null to use the default serializer.
Inherited From:
Source:

notifyPropSet(propName, newValue)

Notify that a property value is set
Parameters:
Name Type Description
propName String Name of property.
newValue Variant New value of the property.
Inherited From:
Source:

objectChange()

Called when object is changed.
Inherited From:
Source:

off(eventName, listener, thisArg)

Remove an event handler, shortcut for (@link ObjectEx.removeEventListener}.
Parameters:
Name Type Description
eventName String Name of event.
listener function Handler function.
thisArg Object The scope object applied when the handler is called. If not set, all listenr function in list will be removed.
Inherited From:
Source:

on(eventName, listener, thisArg) → {Object}

Add an event handler, shortcut for ObjectEx.addEventListener.
Parameters:
Name Type Description
eventName String Name of event.
listener function Handler function.
thisArg Object The scope object applied when the handler is called.
Inherited From:
Source:
Returns:
Handler info object on success, null on fail.
Type
Object

once(eventName, listener, thisArg) → {Object}

Add an event handler that will only be evoked once, shortcut for ObjectEx.addOnceEventListener.
Parameters:
Name Type Description
eventName String Name of event.
listener function Handler function.
thisArg Object The scope object applied when the handler is called.
Inherited From:
Source:
Returns:
Handler info object on success, null on fail.
Type
Object

overwriteMethod(methodName, newMethod) → {ObjectEx}

Overwrite method of object instance (rather than prototype) with a new one.
Parameters:
Name Type Description
methodName String
newMethod Func New function. The arguments of function should be same as overwritten one plus a extra leading param stores the old method. e.g. Overwrite getPropValue method:
var obj = new ObjectEx();
obj.overwriteMethod('getPropValue', function($old, propName)
{
console.log('new method'); return $old(propName); });
Inherited From:
Source:
Returns:
Type
ObjectEx

redraw(context)

Redraw previous object on context with same draw options. Should not be called before draw.
Parameters:
Name Type Description
context Object
Inherited From:
Source:

relayEvent(eventName, event)

Relay event from child of this object.
Parameters:
Name Type Description
eventName String Event to be invoked.
event Object A hash object with information about event.
Inherited From:
Source:

removeEventListener(eventName, listener, thisArg)

Remove an event handler.
Parameters:
Name Type Description
eventName String Name of event.
listener function Handler function.
thisArg Object The scope object applied when the handler is called. If not set, all listenr function in list will be removed.
Inherited From:
Source:

saved()

Called after this object is saved through a serialization system. Descendants may override this.
Inherited From:
Source:

saveObj(destNode, serializerOrName, options)

Save current object to destNode.
Parameters:
Name Type Description
destNode Object Storage node to save object. Different serializer requires different node.
serializerOrName Variant A ObjSerializer instance or name registered in ObjSerializerFactory. Can be null to use the default serializer.
options Hash
Inherited From:
Source:

setPropStoreFieldValue(propName) → {Variant}

Set value of a property's store field. Use this method to set property value and avoid the call of property setter. Readonly property can also be changed in this method. Note: if the property has no store field, this method will has no effect on property.
Parameters:
Name Type Description
propName String Name of property.
Inherited From:
Source:
Returns:
Value of property. If property does not exists, null is returned.
Type
Variant

setPropValue(propName, value, ignoreReadOnly)

Set value of a property.
Parameters:
Name Type Description
propName String Name of property.
value Variant Value of the property.
ignoreReadOnly bool Try set the value directly through store field even if the property is a readonly one (without a setter).
Inherited From:
Source:

setPropValues(hash, ignoreReadOnly)

Set a series of property.
Parameters:
Name Type Description
hash Hash A hash object, its key and values will be used to set property value.
ignoreReadOnly bool Try set the value directly through store field even if the property is a readonly one (without a setter).
Inherited From:
Source:

setPropValueX()

Set value of a property. Similar to ObjectEx.setPropValue but can pass in multiple params. The first param is always the property name while the rest will be put into setter method (setXXX).
Inherited From:
Source:

stopEventPropagation(event)

Stop propagation of event, disallow it to bubble to higher level.
Parameters:
Name Type Description
event Object
Inherited From:
Source:

supportGeometryOptionChange() → {Bool}

Check if changeGeometryOptions is availble to current renderer.
Inherited From:
Source:
Returns:
Type
Bool

update(context, updatedObjs, updateType)

Update a child object inside chemObj. Must be called after draw.
Parameters:
Name Type Description
context Object
updatedObjs Variant Object or Array
updateType Int Value from Kekule.Render.ObjectUpdateType
Inherited From:
Source:

Events

change

Invoked when the object has been modified. event param of it has one fields: {changedPropNames: Array}
Inherited From:
Source:

finalize

Invoked when ObjectEx#finalize is called and the object is released. event param of it has one fields: {obj}
Inherited From:
Source:

propValueSet

Invoked when a property value is set by its setter event param of it has two fields: {propName, propValue} If property enablePropValueSetEvent is false, this event will never be fired.
Inherited From:
Source: