new Viewer2D(parentOrElementOrDocument, chemObj)
An 2D viewer widget for chem objects, actually a specialization of Kekule.ChemWidget.Viewer.
Parameters:
| Name | Type | Description |
|---|---|---|
parentOrElementOrDocument |
Variant | |
chemObj |
Kekule.ChemObject |
Extends
Methods
-
allowAutoSize() → {Bool}
-
Whether current painter can meet the requirement of auto size.
- Inherited From:
- Source:
Returns:
- Type
- Bool
-
backgroundColorChanged()
-
Called after background color is changed, should repaint the context.
-
beginContinuousRepainting()
-
Notify the displayer that in following process, continuous repainting will start and auto size should be disabled. After this phase, endContinuousRepainting() must be called.
-
canModifyPartialGraphic() → {Bool}
-
Whether context and draw bridge can modify existing graphic content.
- Inherited From:
- Source:
Returns:
- Type
- Bool
-
captionIsShown()
-
Returns whether the caption is actually displayed.
- Inherited From:
- Source:
-
changeContextDimension(newDimension) → {Bool}
-
Change the dimension of context.
Parameters:
Name Type Description newDimensionHash - Inherited From:
- Source:
Returns:
Return true if dimension change successfully.- Type
- Bool
-
endContinuousRepainting()
-
Notify the displayer that continuous phase has ended, turn into normal mode.
-
exportToDataUri(dataType, options) → {String}
-
Export drawing content in viewer to a data URL for
tag to use.
Parameters:
Name Type Description dataTypeString Type of image data, e.g. 'image/png'. optionsHash Export options, usually this is a number between 0 and 1 indicating image quality if the requested type is image/jpeg or image/webp. - Inherited From:
- Source:
Returns:
- Type
- String
-
getAllowEditing()
-
Returns whether editor can be lauched in current viewer.
- Inherited From:
- Source:
-
getBackgroundColorOfType(renderType) → {String}
-
Returns background color used for a special renderType.
Parameters:
Name Type Description renderTypeInt - Inherited From:
- Source:
Returns:
- Type
- String
-
getContextDimension() → {Hash}
-
Returns dimension of context.
- Inherited From:
- Source:
Returns:
- Type
- Hash
-
getCoordMode() → {Int}
-
Returns coord mode according to current renderType.
- Inherited From:
- Source:
Returns:
- Type
- Int
-
getCurr2DRotationAngle() → {Float}
-
Returns current 2D rotation angle (in arc).
- Inherited From:
- Source:
Returns:
- Type
- Float
-
getCurr3DRotationInfo() → {Hash}
-
Returns current 3D rotation info.
- Inherited From:
- Source:
Returns:
{rotateMatrix, rotateX, rotateY, rotateZ, rotateAngle, rotateAxisVector}- Type
- Hash
-
getCurrMoleculeDisplayType() → {Int}
-
Returns current molecule display type.
- Inherited From:
- Source:
Returns:
- Type
- Int
-
getCurrZoom() → {Float}
-
Returns zoom property in drawOptions.
- Inherited From:
- Source:
Returns:
- Type
- Float
-
getDrawContextParentElem()
-
Returns parent element to create draw context inside. Descendants can override this method.
-
initialize()
-
isPainting() → {Bool}
-
Returns whether in the painting process.
- Inherited From:
- Source:
Returns:
- Type
- Bool
-
isToolbarEmbedded() → {Bool}
-
Return whether toolbarParentElem is not set the the toolbar is directly embedded in viewer itself.
- Inherited From:
- Source:
Returns:
- Type
- Bool
-
load(chemObj)
-
Load and display chemObj in viewer
Parameters:
Name Type Description chemObjKekule.ChemObject - Inherited From:
- Source:
-
loadFromData(data, mimeType, fromUrlOrFileName)
-
Load chem object from data of special MIME type or file format.
Parameters:
Name Type Description dataVariant Usually text content. mimeTypeString fromUrlOrFileNameString From which file or url is this data loaded. - Inherited From:
- Source:
-
loadFromFile(file)
-
Load chem object from file object. NOTE: browser must support File Reader API to use this method.
Parameters:
Name Type Description fileFile - Inherited From:
- Source:
-
openEditor(callerWidget)
-
Open a popup editor to modify displayed object.
Parameters:
Name Type Description callerWidgetKekule.Widget.BaseWidget Who invokes edit action, default is the viewer itself. - Inherited From:
- Source:
-
prepareSaveData()
-
Called before obj is saved. Descendants can overrride this method.
-
repaint(overrideOptions)
-
Repaint the context with current chem object.
Parameters:
Name Type Description overrideOptionsHash Transform options to do repainting. If this param is set to null, all transform options will be recalculated. If overrideOptions.preserveTransformOptions is true, transform options remains same as last painting process (rather than recalculated). - Inherited From:
- Source:
-
resetDisplay()
-
Reset displayer to initial state (no zoom, rotation and so on).
- Inherited From:
- Source:
-
resetView()
-
Reset viewer to initial state (no zoom, rotation and so on).
- Inherited From:
- Source:
-
resetZoom()
-
Reset to normal size.
- Inherited From:
- Source:
-
rotate2DBy(delta, suspendRendering)
-
Do a 2D rotation base on delta.
Parameters:
Name Type Description deltaFloat In arc. suspendRenderingBool Set this to true if a immediate repaint is not needed. - Inherited From:
- Source:
-
rotate2DTo(angle, suspendRendering)
-
Do a 2D rotation to angle.
Parameters:
Name Type Description angleFloat In arc. suspendRenderingBool Set this to true if a immediate repaint is not needed. - Inherited From:
- Source:
-
rotate3DBy(deltaX, deltaY, deltaZ, suspendRendering)
-
Do a 3D rotation base on delta.
Parameters:
Name Type Description deltaXFloat In arc. deltaYFloat In arc. deltaZFloat In arc. suspendRenderingBool Set this to true if a immediate repaint is not needed. - Inherited From:
- Source:
-
rotate3DByAxis(angle, axisVector, suspendRendering)
-
Do a 3D rotation around axis.
Parameters:
Name Type Description angleFloat In arc. axisVectorHash Axis vector coord. suspendRenderingBool Set this to true if a immediate repaint is not needed. - Inherited From:
- Source:
-
saveData(formatId, dataType, obj) → {Variant}
-
Save loaded chem object to data.
Parameters:
Name Type Description formatIdString dataTypeInt Text or binary. Set null to use default type. objKekule.ChemObject Object to save, default is current chemObj loaded in displayer. - Inherited From:
- Source:
Returns:
Saved data.- Type
- Variant
-
setBackgroundColorOfType(color, renderType)
-
Set background color used for a special renderType.
Parameters:
Name Type Description colorString renderTypeInt -
setCoordMode(coordMode)
-
Set renderType according to coord mode.
Parameters:
Name Type Description coordModeInt - Inherited From:
- Source:
-
setHideHydrogens(newType)
-
Hide or show all hydrogen atoms in 3D model.
Parameters:
Name Type Description newTypeInt Value from Kekule.Render.Molecule2DDisplayType or {@link Kekule.Render.Molecule3DDisplayType}. -
setRotate3DMatrix(matrix, suspendRendering)
-
Set 3D rotation matrix.
Parameters:
Name Type Description matrixArray A 4X4 rotation matrix. suspendRenderingBool Set this to true if a immediate repaint is not needed. - Inherited From:
- Source:
-
updateMenu()
-
Update menu in viewer.
- Inherited From:
- Source:
-
updateToolbar()
-
Update toolbar in viewer.
- Inherited From:
- Source:
-
updateUiComps()
-
Update toolbar and menu in viewer.
- Inherited From:
- Source:
-
zoomIn()
-
Zoom in.
- Inherited From:
- Source:
-
zoomOut()
-
Zoom out.
- Inherited From:
- Source:
-
zoomTo(value, suspendRendering)
-
Zoom to a specified ratio
Parameters:
Name Type Description valueFloat suspendRenderingBool Set this to true if a immediate repaint is not needed. - Inherited From:
- Source:
Events
-
load
-
Invoked when the an chem object (or null) is loaded into the displayer. event param of it has one fields: {obj: Object}
- Inherited From:
- Source: