decreased opacity for edges of other actors
This commit is contained in:
parent
a83b587f49
commit
0b8c6c76ce
31
editor.js
31
editor.js
@ -57,6 +57,13 @@ const curvatureMinMax = 0.2; // Minimum/maximum curvature (1 +/- x) of overlappi
|
||||
|
||||
var selection = null; // The currently selected node/edge.
|
||||
|
||||
const edgeColourDefault = '#999999ff';
|
||||
const edgeColourSelected = '#000000ff';
|
||||
const edgeColourHighlightDefault = 'magenta';
|
||||
const edgeColourHighlightSelected = 'red';
|
||||
const edgeColourSubtleDefault = '#99999955';
|
||||
const edgeColourSubtleSelected = '#00000055';
|
||||
|
||||
|
||||
/**
|
||||
* Checks if two roles are equal.
|
||||
@ -200,7 +207,7 @@ function removeState(state) {
|
||||
* @param {*} node
|
||||
* @returns The colour the given node should have.
|
||||
*/
|
||||
function getColour(node) {
|
||||
function getNodeColour(node) {
|
||||
if (node.stateData && node.stateData.final !== 'False' && node.stateData.final !== '') {
|
||||
if (node.stateData.final === 'True' || node.stateData.final === 'ok') {
|
||||
return selection === node ? '#a4eb34' : '#7fad36';
|
||||
@ -216,17 +223,21 @@ function getColour(node) {
|
||||
}
|
||||
}
|
||||
|
||||
function getEdgeColour(edge) {
|
||||
if (edge.actionData.mode != 'automatic' && edge.actionData.actorNames.includes(selectedActor.value)) {
|
||||
return selection === edge ? edgeColourHighlightSelected : edgeColourHighlightDefault;
|
||||
} else if (selectedActor.value !== 'All Actors') {
|
||||
return selection === edge ? edgeColourSubtleSelected : edgeColourSubtleDefault;
|
||||
} else {
|
||||
return selection === edge ? edgeColourSelected : edgeColourDefault;
|
||||
}
|
||||
}
|
||||
|
||||
const Graph = ForceGraph()
|
||||
(document.getElementById('graph'))
|
||||
.linkDirectionalArrowLength(6)
|
||||
.linkDirectionalArrowRelPos(1)
|
||||
.linkColor(edge => {
|
||||
if (edge.actionData.mode != 'automatic' && edge.actionData.actorNames.includes(selectedActor.value)) {
|
||||
return selection === edge ? 'red' : 'magenta';
|
||||
} else {
|
||||
return selection === edge ? 'black' : '#999999';
|
||||
}
|
||||
})
|
||||
.linkColor(getEdgeColour)
|
||||
.linkCurvature('curvature')
|
||||
.linkCanvasObjectMode(() => 'after')
|
||||
.linkCanvasObject((edge, context) => {
|
||||
@ -306,7 +317,7 @@ const Graph = ForceGraph()
|
||||
|
||||
context.textAlign = 'center';
|
||||
context.textBaseline = 'middle';
|
||||
context.fillStyle = selection === edge ? 'black' : 'darkgrey';
|
||||
context.fillStyle = getEdgeColour(edge);
|
||||
context.fillText(label, 0, 0);
|
||||
context.restore();
|
||||
})
|
||||
@ -316,7 +327,7 @@ const Graph = ForceGraph()
|
||||
.linkDirectionalParticleColor(() => '#00000055')
|
||||
.linkDirectionalParticleWidth(edge => (edge.actionData.mode != 'automatic' && edge.actionData.actorNames.includes(selectedActor.value)) ? 3 : 0)
|
||||
.nodeCanvasObject((node, ctx) => {
|
||||
ctx.fillStyle = getColour(node);
|
||||
ctx.fillStyle = getNodeColour(node);
|
||||
ctx.beginPath();
|
||||
ctx.arc(node.x, node.y, 2*node.val, 0, 2 * Math.PI, false);
|
||||
ctx.fill();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user