synapse fixes

This commit is contained in:
Connor Turland 2014-10-01 19:52:08 -04:00
parent a1925b3573
commit b6700f77f8
2 changed files with 49 additions and 68 deletions

View file

@ -265,7 +265,7 @@ Metamaps.JIT = {
color: Metamaps.Settings.colors.synapses.normal, color: Metamaps.Settings.colors.synapses.normal,
type: 'customEdge', type: 'customEdge',
lineWidth: 2, lineWidth: 2,
alpha: 0.4 alpha: 1
}, },
//Native canvas text styling //Native canvas text styling
Label: { Label: {
@ -574,16 +574,16 @@ Metamaps.JIT = {
//following if statement only executes if the edge being hovered over is not selected //following if statement only executes if the edge being hovered over is not selected
if (edgeIsSelected == -1) { if (edgeIsSelected == -1) {
edge.setData('showDesc', true, 'current'); edge.setData('showDesc', true, 'current');
edge.setDataset('end', {
lineWidth: 4,
alpha: 1
});
Metamaps.Visualize.mGraph.fx.animate({
modes: ['edge-property:lineWidth:color:alpha'],
duration: 100
});
Metamaps.Visualize.mGraph.plot();
} }
edge.setDataset('end', {
lineWidth: 4
});
Metamaps.Visualize.mGraph.fx.animate({
modes: ['edge-property:lineWidth'],
duration: 100
});
Metamaps.Visualize.mGraph.plot();
}, // onMouseEnter }, // onMouseEnter
onMouseLeave: function (edge) { onMouseLeave: function (edge) {
if (edge.getData('alpha') === 0) return; // don't do anything if the edge is filtered if (edge.getData('alpha') === 0) return; // don't do anything if the edge is filtered
@ -592,15 +592,15 @@ Metamaps.JIT = {
//following if statement only executes if the edge being hovered over is not selected //following if statement only executes if the edge being hovered over is not selected
if (edgeIsSelected == -1) { if (edgeIsSelected == -1) {
edge.setData('showDesc', false, 'current'); edge.setData('showDesc', false, 'current');
edge.setDataset('end', {
lineWidth: 2,
alpha: 0.4
});
Metamaps.Visualize.mGraph.fx.animate({
modes: ['edge-property:lineWidth:color:alpha'],
duration: 100
});
} }
edge.setDataset('end', {
lineWidth: 2
});
Metamaps.Visualize.mGraph.fx.animate({
modes: ['edge-property:lineWidth'],
duration: 100
});
Metamaps.Visualize.mGraph.plot(); Metamaps.Visualize.mGraph.plot();
}, // onMouseLeave }, // onMouseLeave
onMouseMoveHandler: function (node, eventInfo, e) { onMouseMoveHandler: function (node, eventInfo, e) {

View file

@ -26,7 +26,7 @@ Metamaps.Settings = {
colors: { colors: {
background: '#344A58', background: '#344A58',
synapses: { synapses: {
normal: '#222222', normal: '#888888',
hover: '#222222', hover: '#222222',
selected: '#FFFFFF' selected: '#FFFFFF'
}, },
@ -2105,17 +2105,11 @@ Metamaps.Control = {
}, },
selectNode: function (node,e) { selectNode: function (node,e) {
if (Metamaps.Selected.Nodes.indexOf(node) != -1) return; var filtered = node.getData('alpha') === 0;
if (filtered || Metamaps.Selected.Nodes.indexOf(node) != -1) return;
node.selected = true; node.selected = true;
node.setData('dim', 30, 'current'); node.setData('dim', 30, 'current');
/*
if(!(e.ctrlKey) && !(e.altKey)){
node.eachAdjacency(function (adj) {
Metamaps.Control.selectEdge(adj);
});
}
*/
Metamaps.Selected.Nodes.push(node); Metamaps.Selected.Nodes.push(node);
}, },
deselectAllNodes: function () { deselectAllNodes: function () {
@ -2128,11 +2122,6 @@ Metamaps.Control = {
}, },
deselectNode: function (node) { deselectNode: function (node) {
delete node.selected; delete node.selected;
/*
node.eachAdjacency(function (adj) {
Metamaps.Control.deselectEdge(adj);
});
*/
node.setData('dim', 25, 'current'); node.setData('dim', 25, 'current');
//remove the node //remove the node
@ -2211,26 +2200,18 @@ Metamaps.Control = {
Metamaps.Filter.checkMappers(); Metamaps.Filter.checkMappers();
}, },
selectEdge: function (edge) { selectEdge: function (edge) {
if (edge.getData('alpha') === 0) return; // don't do anything if the edge is filtered var filtered = edge.getData('alpha') === 0; // don't select if the edge is filtered
if (Metamaps.Selected.Edges.indexOf(edge) != -1) return;
edge.setData('showDesc', true, 'current'); if (filtered || Metamaps.Selected.Edges.indexOf(edge) != -1) return;
if (!Metamaps.Settings.embed) {
edge.setDataset('end', { var width = Metamaps.Mouse.edgeHoveringOver === edge ? 4 : 2;
lineWidth: 4, edge.setDataset('current', {
color: Metamaps.Settings.colors.synapses.selected, showDesc: true,
alpha: 1 lineWidth: width,
}); color: Metamaps.Settings.colors.synapses.selected
} else if (Metamaps.Settings.embed) {
edge.setDataset('end', {
lineWidth: 4,
color: Metamaps.Settings.colors.synapses.selected,
alpha: 1
});
}
Metamaps.Visualize.mGraph.fx.animate({
modes: ['edge-property:lineWidth:color:alpha'],
duration: 100
}); });
Metamaps.Visualize.mGraph.plot();
Metamaps.Selected.Edges.push(edge); Metamaps.Selected.Edges.push(edge);
}, },
deselectAllEdges: function () { deselectAllEdges: function () {
@ -2241,28 +2222,23 @@ Metamaps.Control = {
} }
Metamaps.Visualize.mGraph.plot(); Metamaps.Visualize.mGraph.plot();
}, },
deselectEdge: function (edge) { deselectEdge: function (edge, quick) {
if (edge.getData('alpha') === 0) return; // don't do anything if the edge is filtered
edge.setData('showDesc', false, 'current'); edge.setData('showDesc', false, 'current');
edge.setDataset('end', {
edge.setDataset('current', {
lineWidth: 2, lineWidth: 2,
color: Metamaps.Settings.colors.synapses.normal, color: Metamaps.Settings.colors.synapses.normal
alpha: 0.4
}); });
if (Metamaps.Mouse.edgeHoveringOver == edge) { if (Metamaps.Mouse.edgeHoveringOver == edge) {
edge.setData('showDesc', true, 'current'); edge.setDataset('current', {
edge.setDataset('end', { showDesc: true,
lineWidth: 4, lineWidth: 4,
color: Metamaps.Settings.colors.synapses.hover, color: Metamaps.Settings.colors.synapses.hover
alpha: 1
}); });
} }
Metamaps.Visualize.mGraph.fx.animate({ Metamaps.Visualize.mGraph.plot();
modes: ['edge-property:lineWidth:color:alpha'],
duration: 100
});
//remove the edge //remove the edge
Metamaps.Selected.Edges.splice( Metamaps.Selected.Edges.splice(
@ -2692,8 +2668,11 @@ Metamaps.Filter = {
} }
else { else {
if (n) { if (n) {
// TODO quick deselect node Metamaps.Control.deselectNode(n, true);
n.setData('alpha', 0, 'end'); n.setData('alpha', 0, 'end');
n.eachAdjacency(function(e){
Metamaps.Control.deselectEdge(e, true);
});
} }
else console.log(topic); else console.log(topic);
} }
@ -2712,15 +2691,17 @@ Metamaps.Filter = {
else passesMapper = true; else passesMapper = true;
} }
var color = Metamaps.Settings.colors.synapses.normal;
if (passesSynapse && passesMapper) { if (passesSynapse && passesMapper) {
if (e) { if (e) {
e.setData('alpha', 0.4, 'end'); e.setData('alpha', 1, 'end');
e.setData('color', color, 'end');
} }
else console.log(synapse); else console.log(synapse);
} }
else { else {
if (e) { if (e) {
// TODO quick deselect edge Metamaps.Control.deselectEdge(e, true);
e.setData('alpha', 0, 'end'); e.setData('alpha', 0, 'end');
} }
else console.log(synapse); else console.log(synapse);