Last updated

API / geotoolkit / util / ColorProvider / ColorProvider

Class: ColorProvider

util.ColorProvider.ColorProvider

This abstract class is the parent class of all ColorProviders. A colorprovider converts a value to a color based on its configuration. It's generally created by associating some colors to specific values.
Then it will interpolate (algorithm depends of the actual implementation) those colors on the fly to find the actual color corresponding to a value.
This class also provides a list of built-in color maps KnownScales.
All the color providers inherit from this class, for examples please refer to:
DefaultColorProvider ;
DiscreteGradientColorProvider ;
LogColorProvider ;
RangeColorProvider ;

Hierarchy

Implements

Table of contents

Constructors
Methods
Css Properties
Name Type Description
maxnumber
minnumber
scaleKnownScales

Contents

Constructors

new ColorProvider()

Protected new ColorProvider()

Overrides

EventDispatcher.constructor

Methods

clone

clone(): ColorProvider

Returns clone of color provider

Returns

ColorProvider


copyConstructor

Protected copyConstructor(src): ColorProvider

Copy constructor

Parameters

Name Type Description
srcColorProviderSource to copy from

Returns

ColorProvider

this


dispose

dispose(): void

Dispose.

Returns

void

Inherited from

EventDispatcher.dispose


exportToImage

exportToImage(width, height, isVertical, surface?): Surface

returns surface that represents color map

Parameters

Name Type Description
widthnumberThe image width
heightnumberThe image height
isVerticalbooleanTrue if image is oriented vertically
Optional surfaceSurfaceoutput surface

Returns

Surface

surface The canvas surface


getClassName

getClassName(): string

Returns

string

Inherited from

EventDispatcher.getClassName


getColor

Abstract getColor(value): RgbaColor

Return color for the current value

Parameters

Name Type Description
valuenumbervalue

Returns

RgbaColor

color


getMaxValue

Abstract getMaxValue(): number

Return max

Returns

number

Maximum of ColorProvider


getMinValue

Abstract getMinValue(): number

Return min

Returns

number

Minimum of ColorProvider


getNamedColor

getNamedColor(colorName): string | NamedColorValue

Returns known color value

Parameters

Name Type Description
colorNamestringcolor name, if not specified then returns list of known colors

Returns

string | NamedColorValue

color


getNamedColors

getNamedColors(): NamedColor[]

Returns known colors

Returns

NamedColor[]

array of color pair


getProperties

getProperties(): Options

get properties

Returns

Options

properties


getRaster

getRaster(xMin?, yMin?, xMax?, yMax?): Raster

Returns a new instance of Raster

Parameters

Name Type Description
Optional xMinnumberx Min position to get color
Optional yMinnumbery Min position to get color
Optional xMaxnumberx Max position to get color
Optional yMaxnumbery Max position to get color

Returns

Raster

Implementation of

IRasterable.getRaster


getStopPoints

Abstract getStopPoints(): { color: string ; value: number }[]

Return list of used Stop Points

Returns

{ color: string ; value: number }[]


hasEventListener

hasEventListener(type, callback?): boolean

Check if a list of event listeners for this type contains this listener

Parameters

Name Type Description
typestringtype of event or property
Optional callbackFunctionto be called, if null, check if any callback is registered

Returns

boolean

Inherited from

EventDispatcher.hasEventListener


hasNamedColor

hasNamedColor(colorName): boolean

Check if specified named color exists

Parameters

Name Type Description
colorNamestringcolor name

Returns

boolean

true if color exists


invalidate

Abstract invalidate(): void

invalidate the color provider and fire an event to the visuals

Returns

void


isDisposed

isDisposed(): boolean

Returns whether this object has been disposed

Returns

boolean

Inherited from

EventDispatcher.isDisposed


isNotificationEnabled

Abstract isNotificationEnabled(): boolean

Return state of notification

Returns

boolean


isSilent

isSilent(): boolean

Return true if the event dispatcher doesn't notify any events

Returns

boolean

Inherited from

EventDispatcher.isSilent


notify

notify<E>(type, source, args?): ColorProvider

Notify listeners

Type parameters

NameType
Eextends string

Parameters

Name Type Description
typeEevent types
sourceColorProviderof the event
Optional argsEventMap[E]arguments of the event

Returns

ColorProvider

this

Overrides

EventDispatcher.notify


off

off<E>(type?, callback?): ColorProvider

Detach listener on event. Calling .off() with no arguments removes all attached listeners. Calling .off(type) with no callback removes all attached listeners for specific type.

Type parameters

NameType
Eextends string

Parameters

Name Type Description
Optional typeEtype of the event
Optional callback(eventType: E, sender: ColorProvider, args: EventMap[E]) => voidfunction to be called

Returns

ColorProvider

this

Overrides

EventDispatcher.off


on

on<E>(type, callback): ColorProvider

Attach listener on event that will be called whenever the specified event is delivered to the target

If the callback function is already in the list of event listeners for this target, the function is not added a second time.

If a particular anonymous function is in the list of event listeners registered for a certain target, and then later in the code, an identical anonymous function is given in an "on" call, the second function will also be added to the list of event listeners for that target.

Type parameters

NameType
Eextends string

Parameters

Name Type Description
typeEtype of event or property
callback(eventType: E, sender: ColorProvider, args: EventMap[E]) => voidto be called

Returns

ColorProvider

this

Overrides

EventDispatcher.on


setNamedColor

setNamedColor(colorName, colorValue): ColorProvider

Set color value

Example

import {KnownColors} from '@int/geotoolkit/util/ColorProvider';
colorProvider.setNamedColor(KnownColors.NaN, { // set color for NaN values
'title': 'absent', // title to use when displaying, e.g. by ColorBar shape
'enabled': true, // enable state (default is not false)
'value': 'black' // color to use for NaNs
});

Example

// use 'red' color for values greater than maxValue (default '+∞' title is used)
colorProvider.setNamedColor(KnownColors.PositiveInfinity, 'red');

Parameters

Name Type Description
colorNamestringcolor name
colorValuestring | NamedColorValuecolor or title/value settings object

Returns

ColorProvider

this


setNotification

Abstract setNotification(enable, force?): ColorProvider

Enable / disable notification

Parameters

Name Type Description
enablebooleanenable or disable notifications
Optional forcebooleantrue if parent should be invalidated immediately

Returns

ColorProvider

this


setProperties

setProperties(properties): ColorProvider

set properties

Parameters

Name Type Description
propertiesOptionsproperties

Returns

ColorProvider

this


setSilent

setSilent(bool): ColorProvider

Set silent mode

Parameters

Name Type Description
boolbooleanflag to enable silent mode

Returns

ColorProvider

this

Inherited from

EventDispatcher.setSilent


getClassName

Static getClassName(): string

Returns

string

Inherited from

EventDispatcher.getClassName


getColorProviderType

Static getColorProviderType(objectType?): ClassType<any>

Return ColorProvider constructor from the object class name or type.

Deprecated

since 4.1 Use ColorProvider implementation directly

Parameters

Name Type Description
Optional objectTypestringColorProvider class name

Returns

ClassType<any>

ColorProvider constructor