BaseBehavior
Is an abstract class or interface to be overriden in order to define the way
a given shape should behave when selected or edited by a user. Instances of
BaseBehavior
are internally used by Layer
instances to modify the data
according to a user interaction and a given shape. A single instance of
Behavior
is created in one given shape.
By default, the only method to override to define a new behavior for a
shape is the edit
method. However, if needed in special cases, all the
selection handling can be overriden too.
The flow is the following:
Event
- (forwarded to) -> Layer
- (command) -> Behavior
- (modify) -> data
- (upates) -> Shape
The behavior responsability is then to modify the data according to the user interactions, while shapes are always a view of the current state of the data.
Constructor Summary
Public Constructor | ||
public |
|
Member Summary
Public Members | ||
public set |
The class to add to the shapes when selected. |
|
public get |
The class to add to the shapes when selected. |
|
public get |
An array containing all the selected items of the layer. |
Method Summary
Public Methods | ||
public |
Destroy the references to the selected items. |
|
public |
edit(renderingContext: Object, shape: BaseShape, datum: Object | Array, dx: Number, dy: Number, $target: Element) Interface method to override in order to define its particular behavior when interacted with. |
|
public |
initialize(layer: *) |
|
public |
|
|
public |
toggleSelection($item: Element, datum: Object) |
|
public |
|
Public Constructors
public constructor source
Public Members
Public Methods
public destroy(): String source
Destroy the references to the selected items.
TODO:
- - rename to `clearSelection` (removing the class) ?
public edit(renderingContext: Object, shape: BaseShape, datum: Object | Array, dx: Number, dy: Number, $target: Element) source
Interface method to override in order to define its particular behavior when interacted with.
Params:
Name | Type | Attribute | Description |
renderingContext | Object | The layer rendering context. |
|
shape | BaseShape | The shape object to be edited. |
|
datum | Object | Array | The related datum to modify. |
|
dx | Number | The value of the interaction in the x axis (in pixels). |
|
dy | Number | The value of the interaction in the y axis (in pixels). |
|
$target | Element | The target DOM element of the interaction. |
public initialize(layer: *) source
Params:
Name | Type | Attribute | Description |
layer | * |
public select($item: Element, datum: Object) source
TODO:
- - Pass the shape object to get the accessors ?