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

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:

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

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:

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

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:

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:

Kekule.Render. ChemObjPainter2D

new ChemObjPainter2D()

Source:

Methods

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:

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

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:

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

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:

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: