NGL@1.0.0-beta.7 Home Manual Reference Source Gallery
import ColormakerRegistry from 'ngl/src/color/colormaker-registry.js'
public class | source

ColormakerRegistry

You can directly use an instance of this class. 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
public

Get an description of available scales as an object with id-label as key-value pairs

public
public

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

Remove the scheme with the given id

Private Methods
private

Add a user-defined scheme

private

Public Constructors

public constructor() source

Public Members

public schemes source

public userSchemes source

Public Methods

public add(id: String, scheme: Colormaker): undefined source

Add a scheme with a hardcoded id

Params:

NameTypeAttributeDescription
id String

the id

scheme Colormaker

the colormaker

Return:

undefined

public addScheme(scheme: Function | Colormaker, label: String): String source

Register a custom scheme

Params:

NameTypeAttributeDescription
scheme Function | Colormaker

constructor or Colormaker instance

label String

scheme label

Return:

String

id to refer to the registered scheme

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.

Params:

NameTypeAttributeDescription
dataList Array

cloror-selection pairs

label String

scheme name

Return:

String

id to refer to the registered scheme

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

Return:

Object

available scales

public getScheme() source

public getSchemes(): Object source

Get an description of available schemes as an object with id-label as key-value pairs

Return:

Object

available schemes

public hasScheme(id: String): Boolean source

Check if a scheme with the given id exists

Params:

NameTypeAttributeDescription
id String

the id to check

Return:

Boolean

flag indicating if the scheme exists

public removeScheme(id: String): undefined source

Remove the scheme with the given id

Params:

NameTypeAttributeDescription
id String

scheme to remove

Return:

undefined

Private Methods

private _addUserScheme(scheme: Colormaker, label: String): String source

Add a user-defined scheme

Params:

NameTypeAttributeDescription
scheme Colormaker

the user-defined scheme

label String
  • optional

scheme label

Return:

String

id to refer to the registered scheme

private _createScheme() source