Option name | Type | Description |
---|---|---|
flowviz | FlowViz | A reference to the current instance of the FlowViz library |
Tracks which node is currently selected and displays visual feedback to this end
function NodeSelection(flowviz) {
fv = flowviz;
this.Current = null;
this._shadow = Snap('svg').filter(Snap.filter.shadow(0, 0, 5, "black", 1.0));
this._shadowGreen = Snap('svg').filter(Snap.filter.shadow(0, 0, 5, "green", 0.8));
this._shadowRed = Snap('svg').filter(Snap.filter.shadow(0, 0, 10, "red", 0.6));
fv.on('flowviz-ready', this._Setup);
}
Attaches callbacks onto node click events so that we can track when a node is selected or deselected
NodeSelection.prototype._Setup = function() {
that = this.Selection;
// Clear selections when the background is clicked
d3.selectAll('svg')
.on('click', function(data) {
that.Clear();
});
};
Option name | Type | Description |
---|---|---|
emit |
Clears any selection
NodeSelection.prototype.Clear = function(updating) {
if(updating === undefined) {
updating = false;
}
// Clear the next possible nodes
d3.selectAll('.next-nodes').remove();
// Remove previous selection
d3.select('g.selected-node')
.each(function() {
Snap(this).attr({ filter: null });
})
.classed('selected-node', false);
d3.select('g.selected-edge')
.each(function() {
Snap(this).attr({ filter: null });
})
.classed('selected-edge', false);
if(!updating) {
this.Current = null;
fv.DataEditor.Hide();
fv.emit('selection-cleared');
}
};