Skip to content

API / geotoolkit / widgets / sync / ViewSynchronizer / ViewSynchronizer

Class: ViewSynchronizer

sync.ViewSynchronizer.ViewSynchronizer

Define synchronized space. This class synchronize different nodes.

Example

// How to use custom synchronization
import {ViewSynchronizer} from '@int/geotoolkit/widgets/sync/ViewSynchronizer';
import {SyncMode} from '@int/geotoolkit/widgets/sync/SyncMode';
import {Events as NodeEvents} from '@int/geotoolkit/scene/Node';
import {Orientation} from '@int/geotoolkit/util/Orientation';
import {Transformation} from '@int/geotoolkit/util/Transformation';

const sync = new ViewSynchronizer({'mode': [SyncMode.Custom]});
sync.connect(widget, {
'vertical': true,
'horizontal': true,
'events': [NodeEvents.LocalTransformationChanged]
'custom': {
'getdata' : (item) => item.getLocalTransform(),
'setdata': (tr, item, orientation) => {
const currTransformation = item.getLocalTransform();
let xxModel = currTransformation.getScaleX();
let dxModel = currTransformation.getTranslateX();
let yyModel = currTransformation.getScaleY();
let dyModel = currTransformation.getTranslateY();
if (orientation === Orientation.Vertical) {
yyModel = tr.getScaleY();
dyModel = tr.getTranslateY();
} else if (orientation === Orientation.Horizontal) {
xxModel = tr.getScaleX();
dxModel = tr.getTranslateX();
}
const transformation = new Transformation(xxModel, 0, 0, yyModel, dxModel, dyModel);
widget.setModelTransformation(transformation);
}
}
});

Hierarchy

Table of contents

Constructors
  • [new ViewSynchronizer(options)](/solutions/geotoolkit/GeoToolkit_JS/apis/classes/geotoolkit.widgets-1.sync.viewsynchronizer.viewsynchronizer.md#new viewsynchronizer(options))
Methods

Contents

Constructors

new ViewSynchronizer(options)

• new ViewSynchronizer(options?)

Parameters

Name Type Description
Optional optionsOptionsoptions of synchronization

Overrides

EventDispatcher.constructor

Methods

connect

▸ connect(item, options?): ViewSynchronizer

Connect item to a collection of items to be synchronized

Parameters

Name Type Description
itemAxis | Group<Node&gt; | Layer<Node&gt;item to be added
Optional optionsConnectOptionsoptions to connect listener / receiver

Returns

ViewSynchronizer

this


disconnect

▸ disconnect(item): void

Disconnect item from a collection of items to be synchronized

Parameters

Name Type Description
itemAxis | Group<Node&gt;item to be removed

Returns

void


dispose

▸ dispose(): void

Dispose.

Returns

void

Inherited from

EventDispatcher.dispose


getClassName

▸ getClassName(): string

Returns

string

Inherited from

EventDispatcher.getClassName


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


isDisposed

▸ isDisposed(): boolean

Returns whether this object has been disposed

Returns

boolean

Inherited from

EventDispatcher.isDisposed


isSilent

▸ isSilent(): boolean

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

Returns

boolean

Inherited from

EventDispatcher.isSilent


notify

▸ notify<E&gt;(type, source, args?): ViewSynchronizer

Notify listeners

Type parameters

NameType
Eextends string

Parameters

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

Returns

ViewSynchronizer

this

Overrides

EventDispatcher.notify


off

▸ off<E&gt;(type?, callback?): ViewSynchronizer

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

Returns

ViewSynchronizer

this

Overrides

EventDispatcher.off


on

▸ on<E&gt;(type, callback): ViewSynchronizer

Attach listener on event that will be called whenever the specified event is delivered to the target <p> If the callback function is already in the list of event listeners for this target, the function is not added a second time. </p> <p> 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. </p>

Type parameters

NameType
Eextends string

Parameters

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

Returns

ViewSynchronizer

this

Overrides

EventDispatcher.on


send

▸ send(data, name?): void

Send data for all receivers of the current action

Parameters

Name Type Description
dataSendDatadata
Optional namestringname of the action

Returns

void


setSilent

▸ setSilent(bool): ViewSynchronizer

Set silent mode

Parameters

Name Type Description
boolbooleanflag to enable silent mode

Returns

ViewSynchronizer

this

Inherited from

EventDispatcher.setSilent


synchronize

▸ synchronize(source, name): ViewSynchronizer

Synchronize

Parameters

Name Type Description
sourceAxis | Group<Node&gt;source to synchronize
namestringaction name to applied for synchronization

Returns

ViewSynchronizer

this


getClassName

▸ Static getClassName(): string

Returns

string

Inherited from

EventDispatcher.getClassName