ColormakerRegistry
Class for registering Colormakers. Generally use the global src/globals.js~ColormakerRegistry instance.
Constructor Summary
| Public Constructor | ||
| public |
|
|
Member Summary
| Public Members | ||
| public |
|
|
| public |
|
|
Method Summary
| Public Methods | ||
| public |
add(id: String, scheme: Colormaker): undefined Add a scheme with a hardcoded id |
|
| public |
addScheme(scheme: Function | Colormaker, label: String): String Register a custom scheme |
|
| public |
addSelectionScheme(dataList: Array, label: String): String Create and a selection-based coloring scheme. |
|
| public |
getModes() |
|
| public |
Get an description of available scales as an object with id-label as key-value pairs |
|
| public |
|
|
| public |
getSchemes(): Object Get an description of available schemes as an object with id-label as key-value pairs |
|
| public |
Check if a scheme with the given id exists |
|
| public |
removeScheme(id: String): undefined Remove the scheme with the given id |
|
| Private Methods | ||
| private |
_addUserScheme(scheme: Colormaker, label: String): String Add a user-defined scheme |
|
| private |
|
|
Public Constructors
public constructor() source
Public Methods
public add(id: String, scheme: Colormaker): undefined source
Add a scheme with a hardcoded id
Params:
| Name | Type | Attribute | Description |
| id | String | the id |
|
| scheme | Colormaker | the colormaker |
public addScheme(scheme: Function | Colormaker, label: String): String source
Register a custom scheme
Params:
| Name | Type | Attribute | Description |
| scheme | Function | Colormaker | constructor or Colormaker instance |
|
| label | String | scheme label |
Example:
// Create a class with a `atomColor` method that returns a hex color.
var schemeId = NGL.ColormakerRegistry.addScheme( function( params ){
this.atomColor = function( atom ){
if( atom.serial < 1000 ){
return 0x0000FF; // blue
}else if( atom.serial > 2000 ){
return 0xFF0000; // red
}else{
return 0x00FF00; // green
}
};
} );
stage.loadFile( "rcsb://3dqb.pdb" ).then( function( o ){
o.addRepresentation( "cartoon", { color: schemeId } ); // pass schemeId here
o.autoView();
} );
public addSelectionScheme(dataList: Array, label: String): String source
Create and a selection-based coloring scheme. Supply a list with pairs of colorname and selection for coloring by selections. Use the last entry as a default (catch all) coloring definition.
Example:
var schemeId = NGL.ColormakerRegistry.addSelectionScheme( [
[ "red", "64-74 or 134-154 or 222-254 or 310-310 or 322-326" ],
[ "green", "311-322" ],
[ "yellow", "40-63 or 75-95 or 112-133 or 155-173 or 202-221 or 255-277 or 289-309" ],
[ "blue", "1-39 or 96-112 or 174-201 or 278-288" ],
[ "white", "*" ]
], "Transmembrane 3dqb" );
stage.loadFile( "rcsb://3dqb.pdb" ).then( function( o ){
o.addRepresentation( "cartoon", { color: schemeId } ); // pass schemeId here
o.autoView();
} );
public getModes() source
public getScales(): Object source
Get an description of available scales as an object with id-label as key-value pairs
public getScheme() source
public getSchemes(): Object source
Get an description of available schemes as an object with id-label as key-value pairs
public hasScheme(id: String): Boolean source
Check if a scheme with the given id exists
Params:
| Name | Type | Attribute | Description |
| id | String | the id to check |
public removeScheme(id: String): undefined source
Remove the scheme with the given id
Params:
| Name | Type | Attribute | Description |
| id | String | scheme to remove |
Private Methods
private _addUserScheme(scheme: Colormaker, label: String): String source
Add a user-defined scheme
Params:
| Name | Type | Attribute | Description |
| scheme | Colormaker | the user-defined scheme |
|
| label | String |
|
scheme label |
