Last updated

API / reactnative / plot / Plot / Plot

Class: Plot

plot.Plot.Plot

Defines sender of the events. This class implements a dispatcher/listeners pattern. It's inherited by many classes of the toolkit that requires to send events.
Listeners are callbacks(functions) that can be added and removed at any time. Those will be notified when the corresponding event-type is fired on this object.

Hierarchy

Table of contents

Constructors
Methods

Contents

Constructors

new Plot(options)

new Plot(options?)

Parameters

Name Type
Optional optionsOptions

Overrides

EventDispatcher.constructor

Methods

dispose

dispose(disposeRoot?): void

Disposes the plot and the associated resources.
This may also call dispose on the root node (see disposeRoot).
The plot should not be used/accessed anymore after this has been called.

Parameters

Name Type Description
Optional disposeRootbooleanAlso dispose root node

Returns

void

Overrides

EventDispatcher.dispose


getAutoUpdateInterval

getAutoUpdateInterval(): number

Returns the time interval for autoupdate mechanism.

Returns

number

The time interval in ms


getBoundingClientRect

getBoundingClientRect(): DOMRect

Returns the client rect for the plots container element as DOMRect.

Returns

DOMRect

the client rect for the plots container element


getCanvas

getCanvas(): SkiaView

Returns the canvas element or elements used by this plot

Returns

SkiaView

The canvas element


getClassName

getClassName(): string

Returns

string

Inherited from

EventDispatcher.getClassName


getContainingElement

getContainingElement(): SkiaView

Returns the containing element for the plot

Returns

SkiaView

The canvas


getHeight

getHeight(): number

Returns the containing element height in virtual pixels.
This returns the raw size given at initialization or through the setSize function.
It ignores any Browser zoom.

Returns

number

The canvas height


getRoot

getRoot(): Node

Returns the root node of the scenegraph.

Returns

Node

The root node


getTool

getTool(): ToolsContainer

Returns root tool associated to plot

Returns

ToolsContainer


getWidth

getWidth(): number

Returns the containing element width in virtual pixels.
This returns the raw size given at initialization or through the setSize function.
It ignores any Browser zoom.

Returns

number

The canvas width


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


isAutoUpdate

isAutoUpdate(): boolean

Return true if auto update is enabled.

Returns

boolean

The status of autoupdate


isDisposed

isDisposed(): boolean

Returns whether this object has been disposed

Returns

boolean

Inherited from

EventDispatcher.isDisposed


isInfiniteAutoUpdate

isInfiniteAutoUpdate(): boolean

Return true if infinite auto update is enabled.

Returns

boolean

The status of infinite auto update


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?): Plot

Notify listeners

Type parameters

NameType
Eextends string

Parameters

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

Returns

Plot

this

Overrides

EventDispatcher.notify


off

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

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: Plot, args: EventMap[E]) => voidfunction to be called

Returns

Plot

this

Overrides

EventDispatcher.off


on

on<E>(type, callback): Plot

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: Plot, args: EventMap[E]) => voidto be called

Returns

Plot

this

Overrides

EventDispatcher.on


resumeUpdate

resumeUpdate(refresh?): Plot

Resumes plot update, allowing the update function of triggering a render.

Parameters

Name Type Description
Optional refreshbooleanIf set to true, a render will be run immediately

Returns

Plot

this


setAutoUpdate

setAutoUpdate(enable, infinite?): Plot

Enables or disables auto update mechanism.
If auto update is enabled, whenever a node is invalidated it will trigger a Plot update/render.

Parameters

Name Type Description
enablebooleanThe autoupdate status
Optional infinitebooleanEnables or disables infinite auto update mechanism.
if true, run timer or request animation frame in infinite loop overwise if node is invalidated it will trigger a Plot update/render. if false, browser pixel scale is not updated.

Returns

Plot

this


setAutoUpdateInterval

setAutoUpdateInterval(interval?): Plot

Sets the time interval for autoupdate mechanism.
This will define the delay for polling the status of the Plot and trigger an update/render if necessary.

Parameters

Name Type Description
Optional intervalnumberThe time interval in ms. window.requestAnimationFrame will be used if available and interval set to null.

Returns

Plot

this


setContext

setContext(context): Plot

Parameters

Name Type
contextSkCanvas

Returns

Plot


setRoot

setRoot(root): Plot

Sets the root node ot be the given node.

Parameters

Name Type Description
rootNodeThe scenegraph root node

Returns

Plot

this


setSilent

setSilent(bool): Plot

Set silent mode

Parameters

Name Type Description
boolbooleanflag to enable silent mode

Returns

Plot

this

Inherited from

EventDispatcher.setSilent


setSize

setSize(width, height): Plot

Sets the plot size to the given dimensions.
This will also change the canvas size if autosize is enabled.
If autorootbounds is enabled, this will also update the bounds of the root node.

Parameters

Name Type Description
widthnumberThe width of plot
heightnumberThe height of plot

Returns

Plot

this


setSkiaView

setSkiaView(skiaView): Plot

Parameters

Name Type
skiaViewSkiaView

Returns

Plot


setSurface

setSurface(surface): Plot

Parameters

Name Type
surfaceSkSurface

Returns

Plot


setWatermark

setWatermark(watermark): Plot

Sets watermark to have on a plot

Example

import {Text} from '@int/geotoolkit/scene/shapes/Text';
import {AnchorType} from '@int/geotoolkit/util/AnchorType';
const watermark = new Text({
'alignment': AnchorType.LeftBottom, // watermark position on the screen
'textstyle': {
'font': '60px sans-serif'
},
'text': 'My Watermark'
});
plot.setWatermark(watermark);

Parameters

Name Type Description
watermarkAnchoredShapewatermark shape

Returns

Plot

this


suspendUpdate

suspendUpdate(): Plot

Suspends plot update, preventing the update function from triggering a render.

Returns

Plot

this


update

update(): Plot

Updates the plot, forcing a render.
This will be called automatically when the plot has been marked as dirty if the autoupdate is enabled.

Returns

Plot

this


getClassName

Static getClassName(): string

Returns

string

Inherited from

EventDispatcher.getClassName