Class WireIt.Layer
A layer encapsulate a bunch of containers and wires
Constructor
WireIt.Layer
(
options
)
- Parameters:
-
options
<Object>
Configuration object (see the properties)
Properties
CSS class name for the layer element
Default Value: "WireIt-Layer"
List of all the WireIt.Container (or subclass) instances in this layer
Options for the layer map
Default Value: null
DOM element that schould contain the layer
Default Value: null
List of all the WireIt.Wire (or subclass) instances in this layer
Methods
Array
_getMouseEvtPos
(
e
)
Returns a position relative to the layer from a mouse event
- Parameters:
-
e
<Event>
Mouse event
- Returns:
Array
- position
WireIt.Container
addContainer
(
containerConfig
)
Instanciate a container given its "xtype": WireIt.Container (default) or a subclass of it.
- Parameters:
-
containerConfig
<Object>
Container configuration object (see WireIt.Container class for details)
- Returns:
WireIt.Container
- Container instance build from the xtype
WireIt.Wire
addWire
(
wireConfig
)
Instanciate a wire given its "xtype" (default to WireIt.Wire)
- Parameters:
-
wireConfig
<Object>
Wire configuration object (see WireIt.Wire class for details)
- Returns:
WireIt.Wire
- Wire instance build from the xtype
void
clear
(
)
Remove all the containers in this layer (and the associated terminals and wires)
Obj
getWiring
(
)
Return an object that represent the state of the layer including the containers and the wires
- Returns:
Obj
- layer configuration
void
initContainers
(
)
Create all the containers passed as options
void
initWires
(
)
Create all the wires passed in the config
void
onAddWire
(
event
,
args
)
Update the wire list when any of the containers fired the eventAddWire
- Parameters:
-
event
<Event>
The eventAddWire event fired by the container
-
args
<Array>
This array contains a single element args[0] which is the added Wire instance
void
onRemoveWire
(
event
,
args
)
Update the wire list when a wire is removed
- Parameters:
-
event
<Event>
The eventRemoveWire event fired by the container
-
args
<Array>
This array contains a single element args[0] which is the removed Wire instance
void
onWireClick
(
e
)
Handles click on any wire canvas
Note: we treat mouse events globally so that wires behind others can still receive the events
- Parameters:
-
e
<Event>
Mouse click event
void
onWireMouseMove
(
e
)
Handles mousemove events on any wire canvas
Note: we treat mouse events globally so that wires behind others can still receive the events
- Parameters:
-
e
<Event>
Mouse click event
void
removeAllContainers
(
)
Deprecated Alias for clear
void
removeContainer
(
container
)
Remove a container
- Parameters:
-
container
<WireIt.Container>
Container instance to remove
void
removeGroup
(
)
TODO
void
render
(
)
Create the dom of the layer and insert it into the parent element
void
setOptions
(
)
Set the options by putting them in this (so it overrides the prototype default)
void
setSuperHighlighted
(
)
TODO
void
setWiring
(
wiring
)
Load a layer configuration object
- Parameters:
-
wiring
<Object>
layer configuration
void
unsetSuperHighlighted
(
)
TODO
Events
eventAddContainer
(
)
Event that is fired when a container is added
You can register this event with myTerminal.eventAddContainer.subscribe(function(e,params) { var container=params[0];}, scope);
eventAddWire
(
)
Event that is fired when a wire is added
You can register this event with myTerminal.eventAddWire.subscribe(function(e,params) { var wire=params[0];}, scope);
eventChanged
(
)
Event that is fired when the layer has been changed
You can register this event with myTerminal.eventChanged.subscribe(function(e,params) { }, scope);
eventContainerDragged
(
)
Event that is fired when a container has been moved
You can register this event with myTerminal.eventContainerDragged.subscribe(function(e,params) { var container=params[0];}, scope);
eventContainerResized
(
)
Event that is fired when a container has been resized
You can register this event with myTerminal.eventContainerResized.subscribe(function(e,params) { var container=params[0];}, scope);
eventRemoveContainer
(
)
Event that is fired when a container is removed
You can register this event with myTerminal.eventRemoveContainer.subscribe(function(e,params) { var container=params[0];}, scope);
eventRemoveWire
(
)
Event that is fired when a wire is removed
You can register this event with myTerminal.eventRemoveWire.subscribe(function(e,params) { var wire=params[0];}, scope);