Rename agent highlight to activation for consistency [#26]
This commit is contained in:
parent
bb58943e39
commit
827a94d712
|
@ -539,7 +539,7 @@
|
|||
agentMargin: 10,
|
||||
actionMargin: 10,
|
||||
minActionMargin: 3,
|
||||
agentLineHighlightRadius: 4,
|
||||
agentLineActivationRadius: 4,
|
||||
|
||||
agentCap: {
|
||||
box: {
|
||||
|
@ -945,7 +945,7 @@
|
|||
agentMargin: 8,
|
||||
actionMargin: 5,
|
||||
minActionMargin: 5,
|
||||
agentLineHighlightRadius: 4,
|
||||
agentLineActivationRadius: 4,
|
||||
|
||||
agentCap: {
|
||||
box: {
|
||||
|
@ -1599,14 +1599,14 @@
|
|||
blocked = false,
|
||||
covered = false,
|
||||
group = null,
|
||||
highlighted = false,
|
||||
activated = false,
|
||||
locked = false,
|
||||
visible = false,
|
||||
} = {}) {
|
||||
this.blocked = blocked;
|
||||
this.covered = covered;
|
||||
this.group = group;
|
||||
this.highlighted = highlighted;
|
||||
this.activated = activated;
|
||||
this.locked = locked;
|
||||
this.visible = visible;
|
||||
}
|
||||
|
@ -1659,20 +1659,20 @@
|
|||
const SPECIAL_AGENT_IDS = ['[', ']'];
|
||||
|
||||
const MERGABLE = {
|
||||
'agent activation': {
|
||||
check: ['activated'],
|
||||
merge: ['agentIDs'],
|
||||
siblings: new Set(['agent begin', 'agent end']),
|
||||
},
|
||||
'agent begin': {
|
||||
check: ['mode'],
|
||||
merge: ['agentIDs'],
|
||||
siblings: new Set(['agent highlight']),
|
||||
siblings: new Set(['agent activation']),
|
||||
},
|
||||
'agent end': {
|
||||
check: ['mode'],
|
||||
merge: ['agentIDs'],
|
||||
siblings: new Set(['agent highlight']),
|
||||
},
|
||||
'agent highlight': {
|
||||
check: ['highlighted'],
|
||||
merge: ['agentIDs'],
|
||||
siblings: new Set(['agent begin', 'agent end']),
|
||||
siblings: new Set(['agent activation']),
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -1857,7 +1857,7 @@
|
|||
const PARALLEL_STAGES = [
|
||||
'agent begin',
|
||||
'agent end',
|
||||
'agent highlight',
|
||||
'agent activation',
|
||||
'block begin',
|
||||
'block end',
|
||||
'connect',
|
||||
|
@ -2162,29 +2162,29 @@
|
|||
};
|
||||
}
|
||||
|
||||
setGAgentHighlight(gAgents, highlighted, checked = false) {
|
||||
setGAgentActivation(gAgents, activated, checked = false) {
|
||||
const filteredGAgents = gAgents.filter((gAgent) => {
|
||||
const state = this.getGAgentState(gAgent);
|
||||
if(state.locked || state.blocked) {
|
||||
if(checked) {
|
||||
throw new Error('Cannot highlight agent: ' + gAgent.id);
|
||||
throw new Error('Cannot activate agent: ' + gAgent.id);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return state.visible && (state.highlighted !== highlighted);
|
||||
return state.visible && (state.activated !== activated);
|
||||
});
|
||||
if(filteredGAgents.length === 0) {
|
||||
return null;
|
||||
}
|
||||
filteredGAgents.forEach((gAgent) => {
|
||||
this.updateGAgentState(gAgent, {highlighted});
|
||||
this.updateGAgentState(gAgent, {activated});
|
||||
});
|
||||
|
||||
return {
|
||||
activated,
|
||||
agentIDs: filteredGAgents.map((gAgent) => gAgent.id),
|
||||
highlighted,
|
||||
type: 'agent highlight',
|
||||
type: 'agent activation',
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -2511,7 +2511,7 @@
|
|||
);
|
||||
mergeSets(stopGAgents, endGAgents);
|
||||
if(GAgent.hasIntersection(startGAgents, stopGAgents)) {
|
||||
throw new Error('Cannot set agent highlighting multiple times');
|
||||
throw new Error('Cannot set agent activation multiple times');
|
||||
}
|
||||
|
||||
this.validateGAgents(beginGAgents);
|
||||
|
@ -2601,9 +2601,9 @@
|
|||
_makeConnectParallelStages(flags, connectStage) {
|
||||
return this.makeParallel([
|
||||
this.setGAgentVis(flags.beginGAgents, true, 'box', true),
|
||||
this.setGAgentHighlight(flags.startGAgents, true, true),
|
||||
this.setGAgentActivation(flags.startGAgents, true, true),
|
||||
connectStage,
|
||||
this.setGAgentHighlight(flags.stopGAgents, false, true),
|
||||
this.setGAgentActivation(flags.stopGAgents, false, true),
|
||||
this.setGAgentVis(flags.endGAgents, false, 'cross', true),
|
||||
]);
|
||||
}
|
||||
|
@ -2793,7 +2793,7 @@
|
|||
);
|
||||
this.validateGAgents(gAgents);
|
||||
this.addStage(this.makeParallel([
|
||||
this.setGAgentHighlight(gAgents, false),
|
||||
this.setGAgentActivation(gAgents, false),
|
||||
this.setGAgentVis(gAgents, false, mode, true),
|
||||
...groupPAgents.map(this.endGroup),
|
||||
]), {parallel});
|
||||
|
@ -2866,7 +2866,7 @@
|
|||
|
||||
const terminators = meta.terminators || 'none';
|
||||
this.addStage(this.makeParallel([
|
||||
this.setGAgentHighlight(this.gAgents, false),
|
||||
this.setGAgentActivation(this.gAgents, false),
|
||||
this.setGAgentVis(this.gAgents, false, terminators),
|
||||
]));
|
||||
|
||||
|
@ -2962,7 +2962,7 @@
|
|||
agentMargin: 12,
|
||||
actionMargin: 12,
|
||||
minActionMargin: 4,
|
||||
agentLineHighlightRadius: 4,
|
||||
agentLineActivationRadius: 4,
|
||||
|
||||
agentCap: {
|
||||
box: {
|
||||
|
@ -5288,6 +5288,44 @@
|
|||
return components;
|
||||
}
|
||||
|
||||
class Activation extends BaseComponent {
|
||||
radius(activated, env) {
|
||||
return activated ? env.theme.agentLineActivationRadius : 0;
|
||||
}
|
||||
|
||||
separationPre({agentIDs, activated}, env) {
|
||||
const r = this.radius(activated, env);
|
||||
agentIDs.forEach((id) => {
|
||||
const agentInfo = env.agentInfos.get(id);
|
||||
agentInfo.currentRad = r;
|
||||
agentInfo.currentMaxRad = Math.max(agentInfo.currentMaxRad, r);
|
||||
});
|
||||
}
|
||||
|
||||
renderPre({agentIDs, activated}, env) {
|
||||
const r = this.radius(activated, env);
|
||||
agentIDs.forEach((id) => {
|
||||
const agentInfo = env.agentInfos.get(id);
|
||||
agentInfo.currentMaxRad = Math.max(agentInfo.currentMaxRad, r);
|
||||
});
|
||||
}
|
||||
|
||||
render({agentIDs, activated}, env) {
|
||||
const r = this.radius(activated, env);
|
||||
agentIDs.forEach((id) => {
|
||||
env.drawAgentLine(id, env.primaryY);
|
||||
env.agentInfos.get(id).currentRad = r;
|
||||
});
|
||||
return env.primaryY + env.theme.actionMargin;
|
||||
}
|
||||
|
||||
renderHidden(stage, env) {
|
||||
this.render(stage, env);
|
||||
}
|
||||
}
|
||||
|
||||
register('agent activation', new Activation());
|
||||
|
||||
const OUTLINE_ATTRS = {
|
||||
'class': 'outline',
|
||||
'fill': 'transparent',
|
||||
|
@ -5652,44 +5690,6 @@
|
|||
register('agent begin', new AgentCap(true));
|
||||
register('agent end', new AgentCap(false));
|
||||
|
||||
class AgentHighlight extends BaseComponent {
|
||||
radius(highlighted, env) {
|
||||
return highlighted ? env.theme.agentLineHighlightRadius : 0;
|
||||
}
|
||||
|
||||
separationPre({agentIDs, highlighted}, env) {
|
||||
const r = this.radius(highlighted, env);
|
||||
agentIDs.forEach((id) => {
|
||||
const agentInfo = env.agentInfos.get(id);
|
||||
agentInfo.currentRad = r;
|
||||
agentInfo.currentMaxRad = Math.max(agentInfo.currentMaxRad, r);
|
||||
});
|
||||
}
|
||||
|
||||
renderPre({agentIDs, highlighted}, env) {
|
||||
const r = this.radius(highlighted, env);
|
||||
agentIDs.forEach((id) => {
|
||||
const agentInfo = env.agentInfos.get(id);
|
||||
agentInfo.currentMaxRad = Math.max(agentInfo.currentMaxRad, r);
|
||||
});
|
||||
}
|
||||
|
||||
render({agentIDs, highlighted}, env) {
|
||||
const r = this.radius(highlighted, env);
|
||||
agentIDs.forEach((id) => {
|
||||
env.drawAgentLine(id, env.primaryY);
|
||||
env.agentInfos.get(id).currentRad = r;
|
||||
});
|
||||
return env.primaryY + env.theme.actionMargin;
|
||||
}
|
||||
|
||||
renderHidden(stage, env) {
|
||||
this.render(stage, env);
|
||||
}
|
||||
}
|
||||
|
||||
register('agent highlight', new AgentHighlight());
|
||||
|
||||
const OUTLINE_ATTRS$1 = {
|
||||
'class': 'outline',
|
||||
'fill': 'transparent',
|
||||
|
@ -9185,7 +9185,7 @@
|
|||
agentMargin: 10,
|
||||
actionMargin: 10,
|
||||
minActionMargin: 3,
|
||||
agentLineHighlightRadius: 4,
|
||||
agentLineActivationRadius: 4,
|
||||
|
||||
agentCap: {
|
||||
box: {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -539,7 +539,7 @@
|
|||
agentMargin: 10,
|
||||
actionMargin: 10,
|
||||
minActionMargin: 3,
|
||||
agentLineHighlightRadius: 4,
|
||||
agentLineActivationRadius: 4,
|
||||
|
||||
agentCap: {
|
||||
box: {
|
||||
|
@ -945,7 +945,7 @@
|
|||
agentMargin: 8,
|
||||
actionMargin: 5,
|
||||
minActionMargin: 5,
|
||||
agentLineHighlightRadius: 4,
|
||||
agentLineActivationRadius: 4,
|
||||
|
||||
agentCap: {
|
||||
box: {
|
||||
|
@ -1599,14 +1599,14 @@
|
|||
blocked = false,
|
||||
covered = false,
|
||||
group = null,
|
||||
highlighted = false,
|
||||
activated = false,
|
||||
locked = false,
|
||||
visible = false,
|
||||
} = {}) {
|
||||
this.blocked = blocked;
|
||||
this.covered = covered;
|
||||
this.group = group;
|
||||
this.highlighted = highlighted;
|
||||
this.activated = activated;
|
||||
this.locked = locked;
|
||||
this.visible = visible;
|
||||
}
|
||||
|
@ -1659,20 +1659,20 @@
|
|||
const SPECIAL_AGENT_IDS = ['[', ']'];
|
||||
|
||||
const MERGABLE = {
|
||||
'agent activation': {
|
||||
check: ['activated'],
|
||||
merge: ['agentIDs'],
|
||||
siblings: new Set(['agent begin', 'agent end']),
|
||||
},
|
||||
'agent begin': {
|
||||
check: ['mode'],
|
||||
merge: ['agentIDs'],
|
||||
siblings: new Set(['agent highlight']),
|
||||
siblings: new Set(['agent activation']),
|
||||
},
|
||||
'agent end': {
|
||||
check: ['mode'],
|
||||
merge: ['agentIDs'],
|
||||
siblings: new Set(['agent highlight']),
|
||||
},
|
||||
'agent highlight': {
|
||||
check: ['highlighted'],
|
||||
merge: ['agentIDs'],
|
||||
siblings: new Set(['agent begin', 'agent end']),
|
||||
siblings: new Set(['agent activation']),
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -1857,7 +1857,7 @@
|
|||
const PARALLEL_STAGES = [
|
||||
'agent begin',
|
||||
'agent end',
|
||||
'agent highlight',
|
||||
'agent activation',
|
||||
'block begin',
|
||||
'block end',
|
||||
'connect',
|
||||
|
@ -2162,29 +2162,29 @@
|
|||
};
|
||||
}
|
||||
|
||||
setGAgentHighlight(gAgents, highlighted, checked = false) {
|
||||
setGAgentActivation(gAgents, activated, checked = false) {
|
||||
const filteredGAgents = gAgents.filter((gAgent) => {
|
||||
const state = this.getGAgentState(gAgent);
|
||||
if(state.locked || state.blocked) {
|
||||
if(checked) {
|
||||
throw new Error('Cannot highlight agent: ' + gAgent.id);
|
||||
throw new Error('Cannot activate agent: ' + gAgent.id);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return state.visible && (state.highlighted !== highlighted);
|
||||
return state.visible && (state.activated !== activated);
|
||||
});
|
||||
if(filteredGAgents.length === 0) {
|
||||
return null;
|
||||
}
|
||||
filteredGAgents.forEach((gAgent) => {
|
||||
this.updateGAgentState(gAgent, {highlighted});
|
||||
this.updateGAgentState(gAgent, {activated});
|
||||
});
|
||||
|
||||
return {
|
||||
activated,
|
||||
agentIDs: filteredGAgents.map((gAgent) => gAgent.id),
|
||||
highlighted,
|
||||
type: 'agent highlight',
|
||||
type: 'agent activation',
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -2511,7 +2511,7 @@
|
|||
);
|
||||
mergeSets(stopGAgents, endGAgents);
|
||||
if(GAgent.hasIntersection(startGAgents, stopGAgents)) {
|
||||
throw new Error('Cannot set agent highlighting multiple times');
|
||||
throw new Error('Cannot set agent activation multiple times');
|
||||
}
|
||||
|
||||
this.validateGAgents(beginGAgents);
|
||||
|
@ -2601,9 +2601,9 @@
|
|||
_makeConnectParallelStages(flags, connectStage) {
|
||||
return this.makeParallel([
|
||||
this.setGAgentVis(flags.beginGAgents, true, 'box', true),
|
||||
this.setGAgentHighlight(flags.startGAgents, true, true),
|
||||
this.setGAgentActivation(flags.startGAgents, true, true),
|
||||
connectStage,
|
||||
this.setGAgentHighlight(flags.stopGAgents, false, true),
|
||||
this.setGAgentActivation(flags.stopGAgents, false, true),
|
||||
this.setGAgentVis(flags.endGAgents, false, 'cross', true),
|
||||
]);
|
||||
}
|
||||
|
@ -2793,7 +2793,7 @@
|
|||
);
|
||||
this.validateGAgents(gAgents);
|
||||
this.addStage(this.makeParallel([
|
||||
this.setGAgentHighlight(gAgents, false),
|
||||
this.setGAgentActivation(gAgents, false),
|
||||
this.setGAgentVis(gAgents, false, mode, true),
|
||||
...groupPAgents.map(this.endGroup),
|
||||
]), {parallel});
|
||||
|
@ -2866,7 +2866,7 @@
|
|||
|
||||
const terminators = meta.terminators || 'none';
|
||||
this.addStage(this.makeParallel([
|
||||
this.setGAgentHighlight(this.gAgents, false),
|
||||
this.setGAgentActivation(this.gAgents, false),
|
||||
this.setGAgentVis(this.gAgents, false, terminators),
|
||||
]));
|
||||
|
||||
|
@ -2962,7 +2962,7 @@
|
|||
agentMargin: 12,
|
||||
actionMargin: 12,
|
||||
minActionMargin: 4,
|
||||
agentLineHighlightRadius: 4,
|
||||
agentLineActivationRadius: 4,
|
||||
|
||||
agentCap: {
|
||||
box: {
|
||||
|
@ -5288,6 +5288,44 @@
|
|||
return components;
|
||||
}
|
||||
|
||||
class Activation extends BaseComponent {
|
||||
radius(activated, env) {
|
||||
return activated ? env.theme.agentLineActivationRadius : 0;
|
||||
}
|
||||
|
||||
separationPre({agentIDs, activated}, env) {
|
||||
const r = this.radius(activated, env);
|
||||
agentIDs.forEach((id) => {
|
||||
const agentInfo = env.agentInfos.get(id);
|
||||
agentInfo.currentRad = r;
|
||||
agentInfo.currentMaxRad = Math.max(agentInfo.currentMaxRad, r);
|
||||
});
|
||||
}
|
||||
|
||||
renderPre({agentIDs, activated}, env) {
|
||||
const r = this.radius(activated, env);
|
||||
agentIDs.forEach((id) => {
|
||||
const agentInfo = env.agentInfos.get(id);
|
||||
agentInfo.currentMaxRad = Math.max(agentInfo.currentMaxRad, r);
|
||||
});
|
||||
}
|
||||
|
||||
render({agentIDs, activated}, env) {
|
||||
const r = this.radius(activated, env);
|
||||
agentIDs.forEach((id) => {
|
||||
env.drawAgentLine(id, env.primaryY);
|
||||
env.agentInfos.get(id).currentRad = r;
|
||||
});
|
||||
return env.primaryY + env.theme.actionMargin;
|
||||
}
|
||||
|
||||
renderHidden(stage, env) {
|
||||
this.render(stage, env);
|
||||
}
|
||||
}
|
||||
|
||||
register('agent activation', new Activation());
|
||||
|
||||
const OUTLINE_ATTRS = {
|
||||
'class': 'outline',
|
||||
'fill': 'transparent',
|
||||
|
@ -5652,44 +5690,6 @@
|
|||
register('agent begin', new AgentCap(true));
|
||||
register('agent end', new AgentCap(false));
|
||||
|
||||
class AgentHighlight extends BaseComponent {
|
||||
radius(highlighted, env) {
|
||||
return highlighted ? env.theme.agentLineHighlightRadius : 0;
|
||||
}
|
||||
|
||||
separationPre({agentIDs, highlighted}, env) {
|
||||
const r = this.radius(highlighted, env);
|
||||
agentIDs.forEach((id) => {
|
||||
const agentInfo = env.agentInfos.get(id);
|
||||
agentInfo.currentRad = r;
|
||||
agentInfo.currentMaxRad = Math.max(agentInfo.currentMaxRad, r);
|
||||
});
|
||||
}
|
||||
|
||||
renderPre({agentIDs, highlighted}, env) {
|
||||
const r = this.radius(highlighted, env);
|
||||
agentIDs.forEach((id) => {
|
||||
const agentInfo = env.agentInfos.get(id);
|
||||
agentInfo.currentMaxRad = Math.max(agentInfo.currentMaxRad, r);
|
||||
});
|
||||
}
|
||||
|
||||
render({agentIDs, highlighted}, env) {
|
||||
const r = this.radius(highlighted, env);
|
||||
agentIDs.forEach((id) => {
|
||||
env.drawAgentLine(id, env.primaryY);
|
||||
env.agentInfos.get(id).currentRad = r;
|
||||
});
|
||||
return env.primaryY + env.theme.actionMargin;
|
||||
}
|
||||
|
||||
renderHidden(stage, env) {
|
||||
this.render(stage, env);
|
||||
}
|
||||
}
|
||||
|
||||
register('agent highlight', new AgentHighlight());
|
||||
|
||||
const OUTLINE_ATTRS$1 = {
|
||||
'class': 'outline',
|
||||
'fill': 'transparent',
|
||||
|
@ -9185,7 +9185,7 @@
|
|||
agentMargin: 10,
|
||||
actionMargin: 10,
|
||||
minActionMargin: 3,
|
||||
agentLineHighlightRadius: 4,
|
||||
agentLineActivationRadius: 4,
|
||||
|
||||
agentCap: {
|
||||
box: {
|
||||
|
|
|
@ -15,14 +15,14 @@ class AgentState {
|
|||
blocked = false,
|
||||
covered = false,
|
||||
group = null,
|
||||
highlighted = false,
|
||||
activated = false,
|
||||
locked = false,
|
||||
visible = false,
|
||||
} = {}) {
|
||||
this.blocked = blocked;
|
||||
this.covered = covered;
|
||||
this.group = group;
|
||||
this.highlighted = highlighted;
|
||||
this.activated = activated;
|
||||
this.locked = locked;
|
||||
this.visible = visible;
|
||||
}
|
||||
|
@ -75,20 +75,20 @@ const NOTE_DEFAULT_G_AGENTS = {
|
|||
const SPECIAL_AGENT_IDS = ['[', ']'];
|
||||
|
||||
const MERGABLE = {
|
||||
'agent activation': {
|
||||
check: ['activated'],
|
||||
merge: ['agentIDs'],
|
||||
siblings: new Set(['agent begin', 'agent end']),
|
||||
},
|
||||
'agent begin': {
|
||||
check: ['mode'],
|
||||
merge: ['agentIDs'],
|
||||
siblings: new Set(['agent highlight']),
|
||||
siblings: new Set(['agent activation']),
|
||||
},
|
||||
'agent end': {
|
||||
check: ['mode'],
|
||||
merge: ['agentIDs'],
|
||||
siblings: new Set(['agent highlight']),
|
||||
},
|
||||
'agent highlight': {
|
||||
check: ['highlighted'],
|
||||
merge: ['agentIDs'],
|
||||
siblings: new Set(['agent begin', 'agent end']),
|
||||
siblings: new Set(['agent activation']),
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -273,7 +273,7 @@ function checkDelayedConflicts(allStages) {
|
|||
const PARALLEL_STAGES = [
|
||||
'agent begin',
|
||||
'agent end',
|
||||
'agent highlight',
|
||||
'agent activation',
|
||||
'block begin',
|
||||
'block end',
|
||||
'connect',
|
||||
|
@ -578,29 +578,29 @@ export default class Generator {
|
|||
};
|
||||
}
|
||||
|
||||
setGAgentHighlight(gAgents, highlighted, checked = false) {
|
||||
setGAgentActivation(gAgents, activated, checked = false) {
|
||||
const filteredGAgents = gAgents.filter((gAgent) => {
|
||||
const state = this.getGAgentState(gAgent);
|
||||
if(state.locked || state.blocked) {
|
||||
if(checked) {
|
||||
throw new Error('Cannot highlight agent: ' + gAgent.id);
|
||||
throw new Error('Cannot activate agent: ' + gAgent.id);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return state.visible && (state.highlighted !== highlighted);
|
||||
return state.visible && (state.activated !== activated);
|
||||
});
|
||||
if(filteredGAgents.length === 0) {
|
||||
return null;
|
||||
}
|
||||
filteredGAgents.forEach((gAgent) => {
|
||||
this.updateGAgentState(gAgent, {highlighted});
|
||||
this.updateGAgentState(gAgent, {activated});
|
||||
});
|
||||
|
||||
return {
|
||||
activated,
|
||||
agentIDs: filteredGAgents.map((gAgent) => gAgent.id),
|
||||
highlighted,
|
||||
type: 'agent highlight',
|
||||
type: 'agent activation',
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -927,7 +927,7 @@ export default class Generator {
|
|||
);
|
||||
mergeSets(stopGAgents, endGAgents);
|
||||
if(GAgent.hasIntersection(startGAgents, stopGAgents)) {
|
||||
throw new Error('Cannot set agent highlighting multiple times');
|
||||
throw new Error('Cannot set agent activation multiple times');
|
||||
}
|
||||
|
||||
this.validateGAgents(beginGAgents);
|
||||
|
@ -1017,9 +1017,9 @@ export default class Generator {
|
|||
_makeConnectParallelStages(flags, connectStage) {
|
||||
return this.makeParallel([
|
||||
this.setGAgentVis(flags.beginGAgents, true, 'box', true),
|
||||
this.setGAgentHighlight(flags.startGAgents, true, true),
|
||||
this.setGAgentActivation(flags.startGAgents, true, true),
|
||||
connectStage,
|
||||
this.setGAgentHighlight(flags.stopGAgents, false, true),
|
||||
this.setGAgentActivation(flags.stopGAgents, false, true),
|
||||
this.setGAgentVis(flags.endGAgents, false, 'cross', true),
|
||||
]);
|
||||
}
|
||||
|
@ -1209,7 +1209,7 @@ export default class Generator {
|
|||
);
|
||||
this.validateGAgents(gAgents);
|
||||
this.addStage(this.makeParallel([
|
||||
this.setGAgentHighlight(gAgents, false),
|
||||
this.setGAgentActivation(gAgents, false),
|
||||
this.setGAgentVis(gAgents, false, mode, true),
|
||||
...groupPAgents.map(this.endGroup),
|
||||
]), {parallel});
|
||||
|
@ -1282,7 +1282,7 @@ export default class Generator {
|
|||
|
||||
const terminators = meta.terminators || 'none';
|
||||
this.addStage(this.makeParallel([
|
||||
this.setGAgentHighlight(this.gAgents, false),
|
||||
this.setGAgentActivation(this.gAgents, false),
|
||||
this.setGAgentVis(this.gAgents, false, terminators),
|
||||
]));
|
||||
|
||||
|
|
|
@ -227,6 +227,15 @@ describe('Sequence Generator', () => {
|
|||
};
|
||||
|
||||
const GENERATED = {
|
||||
activation: (agentIDs, activated, {
|
||||
ln = any(),
|
||||
} = {}) => ({
|
||||
activated,
|
||||
agentIDs,
|
||||
ln,
|
||||
type: 'agent activation',
|
||||
}),
|
||||
|
||||
agent: (id, {
|
||||
anchorRight = any(),
|
||||
formattedLabel = any(),
|
||||
|
@ -373,15 +382,6 @@ describe('Sequence Generator', () => {
|
|||
type: 'divider',
|
||||
}),
|
||||
|
||||
highlight: (agentIDs, highlighted, {
|
||||
ln = any(),
|
||||
} = {}) => ({
|
||||
agentIDs,
|
||||
highlighted,
|
||||
ln,
|
||||
type: 'agent highlight',
|
||||
}),
|
||||
|
||||
mark: (name, {
|
||||
ln = any(),
|
||||
} = {}) => ({
|
||||
|
@ -860,7 +860,7 @@ describe('Sequence Generator', () => {
|
|||
]);
|
||||
});
|
||||
|
||||
it('adds parallel highlighting stages to self connections', () => {
|
||||
it('adds parallel activation stages to self connections', () => {
|
||||
const sequence = invoke([
|
||||
PARSED.connect([
|
||||
{flags: ['start'], name: 'A'},
|
||||
|
@ -871,12 +871,12 @@ describe('Sequence Generator', () => {
|
|||
expect(sequence.stages).toEqual([
|
||||
any(),
|
||||
GENERATED.parallel([
|
||||
GENERATED.highlight(['A'], true),
|
||||
GENERATED.activation(['A'], true),
|
||||
GENERATED.connectBegin(['A', 'A'], {label: 'woo!'}),
|
||||
]),
|
||||
GENERATED.parallel([
|
||||
GENERATED.connectEnd(),
|
||||
GENERATED.highlight(['A'], false),
|
||||
GENERATED.activation(['A'], false),
|
||||
]),
|
||||
any(),
|
||||
]);
|
||||
|
@ -1185,7 +1185,7 @@ describe('Sequence Generator', () => {
|
|||
]);
|
||||
});
|
||||
|
||||
it('adds parallel highlighting stages', () => {
|
||||
it('adds parallel activation stages', () => {
|
||||
const sequence = invoke([
|
||||
PARSED.connect(['A', {flags: ['start'], name: 'B'}]),
|
||||
PARSED.connect(['A', {flags: ['stop'], name: 'B'}]),
|
||||
|
@ -1194,12 +1194,12 @@ describe('Sequence Generator', () => {
|
|||
expect(sequence.stages).toEqual([
|
||||
any(),
|
||||
GENERATED.parallel([
|
||||
GENERATED.highlight(['B'], true),
|
||||
GENERATED.activation(['B'], true),
|
||||
GENERATED.connect(['A', 'B']),
|
||||
]),
|
||||
GENERATED.parallel([
|
||||
GENERATED.connect(['A', 'B']),
|
||||
GENERATED.highlight(['B'], false),
|
||||
GENERATED.activation(['B'], false),
|
||||
]),
|
||||
any(),
|
||||
]);
|
||||
|
@ -1235,7 +1235,7 @@ describe('Sequence Generator', () => {
|
|||
]);
|
||||
});
|
||||
|
||||
it('implicitly ends highlighting when ending a stage', () => {
|
||||
it('implicitly ends activation when ending a stage', () => {
|
||||
const sequence = invoke([
|
||||
PARSED.connect(['A', {flags: ['start'], name: 'B'}]),
|
||||
PARSED.connect(['A', {flags: ['end'], name: 'B'}]),
|
||||
|
@ -1246,7 +1246,7 @@ describe('Sequence Generator', () => {
|
|||
any(),
|
||||
GENERATED.parallel([
|
||||
GENERATED.connect(['A', 'B']),
|
||||
GENERATED.highlight(['B'], false),
|
||||
GENERATED.activation(['B'], false),
|
||||
GENERATED.agentEnd(['B']),
|
||||
]),
|
||||
GENERATED.agentEnd(['A']),
|
||||
|
@ -1260,7 +1260,7 @@ describe('Sequence Generator', () => {
|
|||
{flags: ['start', 'stop'], name: 'B'},
|
||||
]),
|
||||
])).toThrow(new Error(
|
||||
'Cannot set agent highlighting multiple times at line 1'
|
||||
'Cannot set agent activation multiple times at line 1'
|
||||
));
|
||||
|
||||
expect(() => invoke([
|
||||
|
@ -1273,7 +1273,7 @@ describe('Sequence Generator', () => {
|
|||
));
|
||||
});
|
||||
|
||||
it('adds implicit highlight end with implicit terminator', () => {
|
||||
it('adds implicit deactivation with implicit terminator', () => {
|
||||
const sequence = invoke([
|
||||
PARSED.connect([
|
||||
'A',
|
||||
|
@ -1285,13 +1285,13 @@ describe('Sequence Generator', () => {
|
|||
any(),
|
||||
any(),
|
||||
GENERATED.parallel([
|
||||
GENERATED.highlight(['B'], false),
|
||||
GENERATED.activation(['B'], false),
|
||||
GENERATED.agentEnd(['A', 'B']),
|
||||
]),
|
||||
]);
|
||||
});
|
||||
|
||||
it('adds implicit highlight end with explicit terminator', () => {
|
||||
it('adds implicit deactivation with explicit terminator', () => {
|
||||
const sequence = invoke([
|
||||
PARSED.connect(['A', {flags: ['start'], name: 'B'}]),
|
||||
PARSED.agentEnd(['A', 'B']),
|
||||
|
@ -1301,13 +1301,13 @@ describe('Sequence Generator', () => {
|
|||
any(),
|
||||
any(),
|
||||
GENERATED.parallel([
|
||||
GENERATED.highlight(['B'], false),
|
||||
GENERATED.activation(['B'], false),
|
||||
GENERATED.agentEnd(['A', 'B']),
|
||||
]),
|
||||
]);
|
||||
});
|
||||
|
||||
it('collapses adjacent end statements containing highlighting', () => {
|
||||
it('collapses adjacent end statements containing activation', () => {
|
||||
const sequence = invoke([
|
||||
PARSED.connect([
|
||||
{flags: ['start'], name: 'A'},
|
||||
|
@ -1321,7 +1321,7 @@ describe('Sequence Generator', () => {
|
|||
any(),
|
||||
any(),
|
||||
GENERATED.parallel([
|
||||
GENERATED.highlight(['A', 'B'], false),
|
||||
GENERATED.activation(['A', 'B'], false),
|
||||
GENERATED.agentEnd(['A', 'B']),
|
||||
]),
|
||||
]);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import './components/Activation.mjs';
|
||||
import './components/AgentCap.mjs';
|
||||
import './components/AgentHighlight.mjs';
|
||||
import './components/Block.mjs';
|
||||
import './components/Connect.mjs';
|
||||
import './components/Divider.mjs';
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import BaseComponent, {register} from './BaseComponent.mjs';
|
||||
|
||||
export default class AgentHighlight extends BaseComponent {
|
||||
radius(highlighted, env) {
|
||||
return highlighted ? env.theme.agentLineHighlightRadius : 0;
|
||||
export default class Activation extends BaseComponent {
|
||||
radius(activated, env) {
|
||||
return activated ? env.theme.agentLineActivationRadius : 0;
|
||||
}
|
||||
|
||||
separationPre({agentIDs, highlighted}, env) {
|
||||
const r = this.radius(highlighted, env);
|
||||
separationPre({agentIDs, activated}, env) {
|
||||
const r = this.radius(activated, env);
|
||||
agentIDs.forEach((id) => {
|
||||
const agentInfo = env.agentInfos.get(id);
|
||||
agentInfo.currentRad = r;
|
||||
|
@ -14,16 +14,16 @@ export default class AgentHighlight extends BaseComponent {
|
|||
});
|
||||
}
|
||||
|
||||
renderPre({agentIDs, highlighted}, env) {
|
||||
const r = this.radius(highlighted, env);
|
||||
renderPre({agentIDs, activated}, env) {
|
||||
const r = this.radius(activated, env);
|
||||
agentIDs.forEach((id) => {
|
||||
const agentInfo = env.agentInfos.get(id);
|
||||
agentInfo.currentMaxRad = Math.max(agentInfo.currentMaxRad, r);
|
||||
});
|
||||
}
|
||||
|
||||
render({agentIDs, highlighted}, env) {
|
||||
const r = this.radius(highlighted, env);
|
||||
render({agentIDs, activated}, env) {
|
||||
const r = this.radius(activated, env);
|
||||
agentIDs.forEach((id) => {
|
||||
env.drawAgentLine(id, env.primaryY);
|
||||
env.agentInfos.get(id).currentRad = r;
|
||||
|
@ -36,4 +36,4 @@ export default class AgentHighlight extends BaseComponent {
|
|||
}
|
||||
}
|
||||
|
||||
register('agent highlight', new AgentHighlight());
|
||||
register('agent activation', new Activation());
|
|
@ -1,18 +1,18 @@
|
|||
import AgentHighlight from './AgentHighlight.mjs';
|
||||
import Activation from './Activation.mjs';
|
||||
import {getComponents} from './BaseComponent.mjs';
|
||||
|
||||
describe('AgentHighlight', () => {
|
||||
const highlight = new AgentHighlight();
|
||||
describe('Activation', () => {
|
||||
const activation = new Activation();
|
||||
|
||||
const theme = {
|
||||
agentLineHighlightRadius: 2,
|
||||
agentLineActivationRadius: 2,
|
||||
};
|
||||
|
||||
it('registers itself with the component store', () => {
|
||||
const components = getComponents();
|
||||
|
||||
expect(components.get('agent highlight')).toEqual(
|
||||
jasmine.any(AgentHighlight)
|
||||
expect(components.get('agent activation')).toEqual(
|
||||
jasmine.any(Activation)
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -24,7 +24,7 @@ describe('AgentHighlight', () => {
|
|||
agentInfos,
|
||||
theme,
|
||||
};
|
||||
highlight.separationPre({agentIDs: ['foo'], highlighted: true}, env);
|
||||
activation.separationPre({activated: true, agentIDs: ['foo']}, env);
|
||||
|
||||
expect(agentInfo.currentRad).toEqual(2);
|
||||
expect(agentInfo.currentMaxRad).toEqual(2);
|
||||
|
@ -38,13 +38,13 @@ describe('AgentHighlight', () => {
|
|||
agentInfos,
|
||||
theme,
|
||||
};
|
||||
highlight.separationPre({agentIDs: ['foo'], highlighted: true}, env);
|
||||
activation.separationPre({activated: true, agentIDs: ['foo']}, env);
|
||||
|
||||
expect(agentInfo.currentRad).toEqual(2);
|
||||
expect(agentInfo.currentMaxRad).toEqual(3);
|
||||
});
|
||||
|
||||
it('sets the radius to 0 when highlighting is disabled', () => {
|
||||
it('sets the radius to 0 when activation is disabled', () => {
|
||||
const agentInfo = {currentMaxRad: 1, currentRad: 0};
|
||||
const agentInfos = new Map();
|
||||
agentInfos.set('foo', agentInfo);
|
||||
|
@ -52,7 +52,7 @@ describe('AgentHighlight', () => {
|
|||
agentInfos,
|
||||
theme,
|
||||
};
|
||||
highlight.separationPre({agentIDs: ['foo'], highlighted: false}, env);
|
||||
activation.separationPre({activated: false, agentIDs: ['foo']}, env);
|
||||
|
||||
expect(agentInfo.currentRad).toEqual(0);
|
||||
expect(agentInfo.currentMaxRad).toEqual(1);
|
|
@ -76,7 +76,7 @@ export default class BasicTheme extends BaseTheme {
|
|||
agentMargin: 10,
|
||||
actionMargin: 10,
|
||||
minActionMargin: 3,
|
||||
agentLineHighlightRadius: 4,
|
||||
agentLineActivationRadius: 4,
|
||||
|
||||
agentCap: {
|
||||
box: {
|
||||
|
|
|
@ -76,7 +76,7 @@ export default class ChunkyTheme extends BaseTheme {
|
|||
agentMargin: 8,
|
||||
actionMargin: 5,
|
||||
minActionMargin: 5,
|
||||
agentLineHighlightRadius: 4,
|
||||
agentLineActivationRadius: 4,
|
||||
|
||||
agentCap: {
|
||||
box: {
|
||||
|
|
|
@ -76,7 +76,7 @@ export default class MonospaceTheme extends BaseTheme {
|
|||
agentMargin: 12,
|
||||
actionMargin: 12,
|
||||
minActionMargin: 4,
|
||||
agentLineHighlightRadius: 4,
|
||||
agentLineActivationRadius: 4,
|
||||
|
||||
agentCap: {
|
||||
box: {
|
||||
|
|
|
@ -126,7 +126,7 @@ export default class SketchTheme extends BaseTheme {
|
|||
agentMargin: 10,
|
||||
actionMargin: 10,
|
||||
minActionMargin: 3,
|
||||
agentLineHighlightRadius: 4,
|
||||
agentLineActivationRadius: 4,
|
||||
|
||||
agentCap: {
|
||||
box: {
|
||||
|
|
Loading…
Reference in New Issue