API / geotoolkit / widgets / sync / ViewSynchronizer / 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);
}
}
});↳
ViewSynchronizer
Constructors
Methods
Constructors
• new ViewSynchronizer(options?)
| Name | Type | Description |
|---|---|---|
Optional options | Options | options of synchronization |
EventDispatcher.constructor
Methods
▸ connect(item, options?): ViewSynchronizer
Connect item to a collection of items to be synchronized
| Name | Type | Description |
|---|---|---|
item | Axis | Group<Node> | Layer<Node> | item to be added |
Optional options | ConnectOptions | options to connect listener / receiver |
this
▸ disconnect(item): void
Disconnect item from a collection of items to be synchronized
void
▸ dispose(): void
Dispose.
void
▸ getClassName(): string
string
▸ 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
▸ isDisposed(): boolean
Returns whether this object has been disposed
boolean
▸ isSilent(): boolean
Return true if the event dispatcher doesn't notify any events
boolean
▸ notify<E>(type, source, args?): ViewSynchronizer
Notify listeners
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | event types |
source | ViewSynchronizer | of the event |
Optional args | EventMap[E] | arguments of the event |
this
▸ off<E>(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.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
Optional type | E | type of the event |
Optional callback | (eventType: E, sender: ViewSynchronizer, args: EventMap[E]) => void | function to be called |
this
▸ on<E>(type, callback): ViewSynchronizer
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: ViewSynchronizer, args: EventMap[E]) => void | to be called |
this
▸ send(data, name?): void
Send data for all receivers of the current action
| Name | Type | Description |
|---|---|---|
data | SendData | data |
Optional name | string | name of the action |
void
▸ setSilent(bool): ViewSynchronizer
Set silent mode
| Name | Type | Description |
|---|---|---|
bool | boolean | flag to enable silent mode |
this
▸ synchronize(source, name): ViewSynchronizer
Synchronize
| Name | Type | Description |
|---|---|---|
source | Axis | Group<Node> | source to synchronize |
name | string | action name to applied for synchronization |
this
▸ Static getClassName(): string
string