API / geotoolkit / util / ColorProvider / 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 ;
↳
ColorProvider↳↳
ColorMap
Constructors
Methods
Css Properties
| Name | Type | Description |
|---|---|---|
max | number | |
min | number | |
scale | KnownScales |
Methods
▸ clone(): ColorProvider
Returns clone of color provider
▸ Protected copyConstructor(src): ColorProvider
Copy constructor
| Name | Type | Description |
|---|---|---|
src | ColorProvider | Source to copy from |
this
▸ dispose(): void
Dispose.
void
▸ exportToImage(width, height, isVertical, surface?): Surface
returns surface that represents color map
| Name | Type | Description |
|---|---|---|
width | number | The image width |
height | number | The image height |
isVertical | boolean | True if image is oriented vertically |
Optional surface | Surface | output surface |
surface The canvas surface
▸ getClassName(): string
string
▸ Abstract getColor(value): RgbaColor
Return color for the current value
| Name | Type | Description |
|---|---|---|
value | number | value |
color
▸ Abstract getMaxValue(): number
Return max
number
Maximum of ColorProvider
▸ Abstract getMinValue(): number
Return min
number
Minimum of ColorProvider
▸ getNamedColor(colorName): string | NamedColorValue
Returns known color value
| Name | Type | Description |
|---|---|---|
colorName | string | color name, if not specified then returns list of known colors |
string | NamedColorValue
color
▸ getNamedColors(): NamedColor[]
Returns known colors
array of color pair
▸ getProperties(): Options
get properties
properties
▸ getRaster(xMin?, yMin?, xMax?, yMax?): Raster
Returns a new instance of Raster
| Name | Type | Description |
|---|---|---|
Optional xMin | number | x Min position to get color |
Optional yMin | number | y Min position to get color |
Optional xMax | number | x Max position to get color |
Optional yMax | number | y Max position to get color |
▸ Abstract getStopPoints(): { color: string ; value: number }[]
Return list of used Stop Points
{ color: string ; value: number }[]
▸ hasEventListener(type, callback?): boolean
Check if a list of event listeners for this type contains this listener
| Name | Type | Description |
|---|---|---|
type | string | type of event or property |
Optional callback | Function | to be called, if null, check if any callback is registered |
boolean
EventDispatcher.hasEventListener
▸ hasNamedColor(colorName): boolean
Check if specified named color exists
| Name | Type | Description |
|---|---|---|
colorName | string | color name |
boolean
true if color exists
▸ Abstract invalidate(): void
invalidate the color provider and fire an event to the visuals
void
▸ isDisposed(): boolean
Returns whether this object has been disposed
boolean
▸ Abstract isNotificationEnabled(): boolean
Return state of notification
boolean
▸ isSilent(): boolean
Return true if the event dispatcher doesn't notify any events
boolean
▸ notify<E>(type, source, args?): ColorProvider
Notify listeners
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | event types |
source | ColorProvider | of the event |
Optional args | EventMap[E] | arguments of the event |
this
▸ 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.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
Optional type | E | type of the event |
Optional callback | (eventType: E, sender: ColorProvider, args: EventMap[E]) => void | function to be called |
this
▸ 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.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | type of event or property |
callback | (eventType: E, sender: ColorProvider, args: EventMap[E]) => void | to be called |
this
▸ 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');| Name | Type | Description |
|---|---|---|
colorName | string | color name |
colorValue | string | NamedColorValue | color or title/value settings object |
this
▸ Abstract setNotification(enable, force?): ColorProvider
Enable / disable notification
| Name | Type | Description |
|---|---|---|
enable | boolean | enable or disable notifications |
Optional force | boolean | true if parent should be invalidated immediately |
this
▸ setProperties(properties): ColorProvider
set properties
| Name | Type | Description |
|---|---|---|
properties | Options | properties |
this
▸ setSilent(bool): ColorProvider
Set silent mode
| Name | Type | Description |
|---|---|---|
bool | boolean | flag to enable silent mode |
this
▸ Static getClassName(): string
string
▸ Static getColorProviderType(objectType?): ClassType<any>
Return ColorProvider constructor from the object class name or type.
Deprecated
since 4.1 Use ColorProvider implementation directly
| Name | Type | Description |
|---|---|---|
Optional objectType | string | ColorProvider class name |
ClassType<any>
ColorProvider constructor