API / geotoolkit / plot / Plot / Plot
A plot with 2D rendering capabilities.
The plot requires a canvas to be passed in the options to render its content.
The plot is internally structured as a SceneGraph, using Node.
Each node having a scene-transform transformation that will be applied at render time.
The plot offers an autoupdate behavior that will check regularly if a render is required (using requestanimationframe if available, polling otherwise).
When this autoupdate lands, the plot will check if it is flagged as dirty.
If so, it will trigger a render phase.
This mechanism can be configured when instantiating the Plot or changed using the corresponding setters.
One could also temporarily suspend any rendering by calling suspendUpdate in order to apply large scale changes or simply force the plot to hibernate when not used/visible.
If the autoupdate mechanism is not enabled, the client code is responsible of calling the update function to tell the plot that it should render itself.
Throws
if parameter canvasElement is not HTMLCanvasElement or HTML5 Canvas is not supported.
↳
Plot
Constructors
Methods
Constructors
• new Plot(options?)
Creates plot
| Name | Type | Description |
|---|---|---|
Optional options | Options | plot options |
EventDispatcher.constructor
Methods
▸ 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.
| Name | Type | Description |
|---|---|---|
Optional disposeRoot | boolean | Also dispose root node |
void
▸ getAutoUpdateInterval(): number
Returns the time interval for autoupdate mechanism.
number
The time interval in ms
▸ getBoundingClientRect(): DOMRect
Returns the client rect for the plots container element as DOMRect.
DOMRect
the client rect for the plots container element
▸ getCanvas(): HTMLCanvasElement | HTMLCanvasElement[]
Returns the canvas element or elements used by this plot
HTMLCanvasElement | HTMLCanvasElement[]
The canvas element
▸ getClassName(): string
string
▸ getContainingElement(): HTMLElement
Returns the containing element for the plot
This is either the canvas element or the div element depending on the chosen functionality
HTMLElement
The canvas width
▸ 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.
number
The canvas height
▸ getRoot(): Node
Returns the root node of the scenegraph.
The root node
▸ getTool(): ToolsContainer
Returns root tool associated to plot
▸ 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.
number
The canvas width
▸ 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
▸ isAutoUpdate(): boolean
Return true if auto update is enabled.
boolean
The status of autoupdate
▸ isDisposed(): boolean
Returns whether this object has been disposed
boolean
▸ isInfiniteAutoUpdate(): boolean
Return true if infinite auto update is enabled.
boolean
The status of infinite auto update
▸ isSilent(): boolean
Return true if the event dispatcher doesn't notify any events
boolean
▸ notify<E>(type, source, args?): Plot
Notify listeners
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | event types |
source | Plot | of the event |
Optional args | EventMap[E] | arguments of the event |
this
▸ 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.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
Optional type | E | type of the event |
Optional callback | (eventType: E, sender: Plot, args: EventMap[E]) => void | function to be called |
this
▸ 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.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | type of event or property |
callback | (eventType: E, sender: Plot, args: EventMap[E]) => void | to be called |
this
▸ onResize(): Plot
Forces a resize on the plot using its known width and height.
this
▸ resumeUpdate(refresh?): Plot
Resumes plot update, allowing the update function of triggering a render.
| Name | Type | Description |
|---|---|---|
Optional refresh | boolean | If set to true, a render will be run immediately |
this
▸ setAutoSize(autoSize): Plot
Enable or disable autosize mechanism.
If enabled, this will let the Plot resize the associated canvas whenever the plot itself is resized.
| Name | Type | Description |
|---|---|---|
autoSize | boolean | The status of autosize |
this
▸ 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.
| Name | Type | Description |
|---|---|---|
enable | boolean | The autoupdate status |
Optional infinite | boolean | Enables 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. |
this
▸ 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.
| Name | Type | Description |
|---|---|---|
Optional interval | number | The time interval in ms. window.requestAnimationFrame will be used if available and interval set to null. |
this
▸ setRoot(root): Plot
Sets the root node ot be the given node.
| Name | Type | Description |
|---|---|---|
root | Node | The scenegraph root node |
this
▸ setSilent(bool): Plot
Set silent mode
| Name | Type | Description |
|---|---|---|
bool | boolean | flag to enable silent mode |
this
▸ 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.
| Name | Type | Description |
|---|---|---|
width | number | The width of plot |
height | number | The height of plot |
this
▸ 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);| Name | Type | Description |
|---|---|---|
watermark | AnchoredShape | watermark shape |
this
▸ suspendUpdate(): Plot
Suspends plot update, preventing the update function from triggering a render.
this
▸ 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.
this
▸ Static getClassName(): string
string
▸ Static getPlotByNode(node): Plot
Get registered plot associated with node
| Name | Type | Description |
|---|---|---|
node | Node | node on plot |
plot
▸ Static setEnableDevTool(enabled): void
Enable/disable dev tool support
| Name | Type | Description |
|---|---|---|
enabled | boolean | True to enable dev tool support, false otherwise |
void