Stage
Stage class, central for creating molecular scenes with NGL.
Example:
var stage = new Stage( "elementId", { backgroundColor: "white" } );
Constructor Summary
Public Constructor | ||
public |
constructor(idOrElement: String | Element, params: StageParameters) Create a Stage instance |
Member Summary
Public Members | ||
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
Events emitted by the stage |
|
public |
|
|
public |
Counter that keeps track of various potentially long-running tasks, including file loading and surface calculation. |
|
public |
tooltip: Element Tooltip element |
|
public |
|
|
public |
|
|
public |
|
Method Summary
Public Methods | ||
public |
addComponent(component: Component): undefined Add the given component to the stage |
|
public |
addComponentFromObject(object: Script | Shape | Structure | Surface | Volume, params: ComponentParameters): Component Create a component from the given object and add to the stage |
|
public |
Add a zoom and a move animation with automatic targets |
|
public |
Create default representations for the given component |
|
public |
Cleanup when disposing of a stage object |
|
public |
eachComponent(callback: Function, type: String): undefined Iterator over each component and executing the callback |
|
public |
eachRepresentation(callback: Function, type: String): undefined Iterator over each representation and executing the callback |
|
public |
getAnythingByName(name: String | RegExp): Collection Get collection of components and representations by name |
|
public |
getBox() |
|
public |
|
|
public |
getComponentsByName(name: String | RegExp, type: String): ComponentCollection Get collection of components by name |
|
public |
getComponentsByObject(object: Object): ComponentCollection Get collection of components by object |
|
public |
Get stage parameters |
|
public |
getRepresentationsByName(name: String | RegExp, type: String): RepresentationCollection Get collection of representations by name |
|
public |
getZoom() |
|
public |
|
|
public |
Handle any size-changes of the container element |
|
public |
loadFile(path: String | File | Blob, params: LoaderParameters): Promise Load a file onto the stage |
|
public |
makeImage(params: ImageParameters): Promise Make image from what is shown in a viewer canvas |
|
public |
removeAllComponents(type: String): undefined Remove all components from the stage |
|
public |
removeComponent(component: Component): undefined Remove the given component |
|
public |
setFocus() |
|
public |
|
|
public |
setParameters(params: StageParameters): Stage Set stage parameters |
|
public |
|
|
public |
Set rock |
|
public |
Set width and height |
|
public |
Set spin |
|
public |
toggleFullscreen(element: Element): undefined Toggle fullscreen |
|
public |
Toggle rock |
|
public |
Toggle spin |
Public Constructors
public constructor(idOrElement: String | Element, params: StageParameters) source
Create a Stage instance
Params:
Name | Type | Attribute | Description |
idOrElement | String | Element |
|
dom id or element |
params | StageParameters | parameters object |
Public Members
public animationBehavior source
public animationControls: AnimationControls source
public compList source
public defaultFileParams source
public keyBehavior source
public keyControls: KeyControls source
public lastFullscreenElement source
public mouseBehavior source
public mouseControls: MouseControls source
public mouseObserver: MouseObserver source
public parameters source
public pickingBehavior source
public pickingControls source
public rockAnimation: RockAnimation source
public spinAnimation: SpinAnimation source
public tasks: Counter source
Counter that keeps track of various potentially long-running tasks, including file loading and surface calculation.
public trackballControls source
public viewer source
public viewerControls: ViewerControls source
Public Methods
public addComponent(component: Component): undefined source
Add the given component to the stage
Params:
Name | Type | Attribute | Description |
component | Component | the component to add |
public addComponentFromObject(object: Script | Shape | Structure | Surface | Volume, params: ComponentParameters): Component source
Create a component from the given object and add to the stage
public autoView(duration: Integer): undefined source
Add a zoom and a move animation with automatic targets
Params:
Name | Type | Attribute | Description |
duration | Integer | animation time in milliseconds |
public defaultFileRepresentation(object: StructureComponent | SurfaceComponent): undefined source
Create default representations for the given component
Params:
Name | Type | Attribute | Description |
object | StructureComponent | SurfaceComponent | component to create the representations for |
public eachComponent(callback: Function, type: String): undefined source
Iterator over each component and executing the callback
public eachRepresentation(callback: Function, type: String): undefined source
Iterator over each representation and executing the callback
public getAnythingByName(name: String | RegExp): Collection source
Get collection of components and representations by name
public getBox() source
public getCenter() source
public getComponentsByName(name: String | RegExp, type: String): ComponentCollection source
Get collection of components by name
public getComponentsByObject(object: Object): ComponentCollection source
Get collection of components by object
Params:
Name | Type | Attribute | Description |
object | Object | the object to find |
public getRepresentationsByName(name: String | RegExp, type: String): RepresentationCollection source
Get collection of representations by name
public getZoom() source
public getZoomForBox() source
public loadFile(path: String | File | Blob, params: LoaderParameters): Promise source
Load a file onto the stage
Params:
Name | Type | Attribute | Description |
path | String | File | Blob | either a URL or an object containing the file data |
|
params | LoaderParameters | loading parameters |
|
params.asTrajectory | Boolean | load multi-model structures as a trajectory |
Return:
Promise | A Promise object that resolves to a StructureComponent, a SurfaceComponent or a ScriptComponent object, depending on the type of the loaded file. |
Example:
// load from URL
stage.loadFile( "http://files.rcsb.org/download/5IOS.cif" );
// load binary data in CCP4 format via a Blob
var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );
stage.loadFile( binaryBlob, { ext: "ccp4" } );
// load string data in PDB format via a Blob
var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );
stage.loadFile( stringBlob, { ext: "pdb" } );
// load a File object
stage.loadFile( file );
// load from URL and add a 'ball+stick' representation with double/triple bonds
stage.loadFile( "http://files.rcsb.org/download/1crn.cif" ).then( function( comp ){
comp.addRepresentation( "ball+stick", { multipleBond: true } );
} );
public makeImage(params: ImageParameters): Promise source
Make image from what is shown in a viewer canvas
Params:
Name | Type | Attribute | Description |
params | ImageParameters | image generation parameters |
public removeAllComponents(type: String): undefined source
Remove all components from the stage
Params:
Name | Type | Attribute | Description |
type | String |
|
component type to remove |
public removeComponent(component: Component): undefined source
Remove the given component
Params:
Name | Type | Attribute | Description |
component | Component | the component to remove |
public setFocus() source
public setImpostor() source
public setParameters(params: StageParameters): Stage source
Set stage parameters
Params:
Name | Type | Attribute | Description |
params | StageParameters | stage parameters |
public setQuality() source
public setRock(flag: Boolean): undefined source
Set rock
Params:
Name | Type | Attribute | Description |
flag | Boolean | if true start rocking and stop spinning |
public setSpin(flag: Boolean): undefined source
Set spin
Params:
Name | Type | Attribute | Description |
flag | Boolean | if true start rocking and stop spinning |