Rename agent highlight to activation for consistency [#26]

This commit is contained in:
David Evans 2018-05-12 20:19:01 +01:00
parent bb58943e39
commit 827a94d712
12 changed files with 197 additions and 197 deletions

View File

@ -539,7 +539,7 @@
agentMargin: 10, agentMargin: 10,
actionMargin: 10, actionMargin: 10,
minActionMargin: 3, minActionMargin: 3,
agentLineHighlightRadius: 4, agentLineActivationRadius: 4,
agentCap: { agentCap: {
box: { box: {
@ -945,7 +945,7 @@
agentMargin: 8, agentMargin: 8,
actionMargin: 5, actionMargin: 5,
minActionMargin: 5, minActionMargin: 5,
agentLineHighlightRadius: 4, agentLineActivationRadius: 4,
agentCap: { agentCap: {
box: { box: {
@ -1599,14 +1599,14 @@
blocked = false, blocked = false,
covered = false, covered = false,
group = null, group = null,
highlighted = false, activated = false,
locked = false, locked = false,
visible = false, visible = false,
} = {}) { } = {}) {
this.blocked = blocked; this.blocked = blocked;
this.covered = covered; this.covered = covered;
this.group = group; this.group = group;
this.highlighted = highlighted; this.activated = activated;
this.locked = locked; this.locked = locked;
this.visible = visible; this.visible = visible;
} }
@ -1659,20 +1659,20 @@
const SPECIAL_AGENT_IDS = ['[', ']']; const SPECIAL_AGENT_IDS = ['[', ']'];
const MERGABLE = { const MERGABLE = {
'agent activation': {
check: ['activated'],
merge: ['agentIDs'],
siblings: new Set(['agent begin', 'agent end']),
},
'agent begin': { 'agent begin': {
check: ['mode'], check: ['mode'],
merge: ['agentIDs'], merge: ['agentIDs'],
siblings: new Set(['agent highlight']), siblings: new Set(['agent activation']),
}, },
'agent end': { 'agent end': {
check: ['mode'], check: ['mode'],
merge: ['agentIDs'], merge: ['agentIDs'],
siblings: new Set(['agent highlight']), siblings: new Set(['agent activation']),
},
'agent highlight': {
check: ['highlighted'],
merge: ['agentIDs'],
siblings: new Set(['agent begin', 'agent end']),
}, },
}; };
@ -1857,7 +1857,7 @@
const PARALLEL_STAGES = [ const PARALLEL_STAGES = [
'agent begin', 'agent begin',
'agent end', 'agent end',
'agent highlight', 'agent activation',
'block begin', 'block begin',
'block end', 'block end',
'connect', 'connect',
@ -2162,29 +2162,29 @@
}; };
} }
setGAgentHighlight(gAgents, highlighted, checked = false) { setGAgentActivation(gAgents, activated, checked = false) {
const filteredGAgents = gAgents.filter((gAgent) => { const filteredGAgents = gAgents.filter((gAgent) => {
const state = this.getGAgentState(gAgent); const state = this.getGAgentState(gAgent);
if(state.locked || state.blocked) { if(state.locked || state.blocked) {
if(checked) { if(checked) {
throw new Error('Cannot highlight agent: ' + gAgent.id); throw new Error('Cannot activate agent: ' + gAgent.id);
} else { } else {
return false; return false;
} }
} }
return state.visible && (state.highlighted !== highlighted); return state.visible && (state.activated !== activated);
}); });
if(filteredGAgents.length === 0) { if(filteredGAgents.length === 0) {
return null; return null;
} }
filteredGAgents.forEach((gAgent) => { filteredGAgents.forEach((gAgent) => {
this.updateGAgentState(gAgent, {highlighted}); this.updateGAgentState(gAgent, {activated});
}); });
return { return {
activated,
agentIDs: filteredGAgents.map((gAgent) => gAgent.id), agentIDs: filteredGAgents.map((gAgent) => gAgent.id),
highlighted, type: 'agent activation',
type: 'agent highlight',
}; };
} }
@ -2511,7 +2511,7 @@
); );
mergeSets(stopGAgents, endGAgents); mergeSets(stopGAgents, endGAgents);
if(GAgent.hasIntersection(startGAgents, stopGAgents)) { 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); this.validateGAgents(beginGAgents);
@ -2601,9 +2601,9 @@
_makeConnectParallelStages(flags, connectStage) { _makeConnectParallelStages(flags, connectStage) {
return this.makeParallel([ return this.makeParallel([
this.setGAgentVis(flags.beginGAgents, true, 'box', true), this.setGAgentVis(flags.beginGAgents, true, 'box', true),
this.setGAgentHighlight(flags.startGAgents, true, true), this.setGAgentActivation(flags.startGAgents, true, true),
connectStage, connectStage,
this.setGAgentHighlight(flags.stopGAgents, false, true), this.setGAgentActivation(flags.stopGAgents, false, true),
this.setGAgentVis(flags.endGAgents, false, 'cross', true), this.setGAgentVis(flags.endGAgents, false, 'cross', true),
]); ]);
} }
@ -2793,7 +2793,7 @@
); );
this.validateGAgents(gAgents); this.validateGAgents(gAgents);
this.addStage(this.makeParallel([ this.addStage(this.makeParallel([
this.setGAgentHighlight(gAgents, false), this.setGAgentActivation(gAgents, false),
this.setGAgentVis(gAgents, false, mode, true), this.setGAgentVis(gAgents, false, mode, true),
...groupPAgents.map(this.endGroup), ...groupPAgents.map(this.endGroup),
]), {parallel}); ]), {parallel});
@ -2866,7 +2866,7 @@
const terminators = meta.terminators || 'none'; const terminators = meta.terminators || 'none';
this.addStage(this.makeParallel([ this.addStage(this.makeParallel([
this.setGAgentHighlight(this.gAgents, false), this.setGAgentActivation(this.gAgents, false),
this.setGAgentVis(this.gAgents, false, terminators), this.setGAgentVis(this.gAgents, false, terminators),
])); ]));
@ -2962,7 +2962,7 @@
agentMargin: 12, agentMargin: 12,
actionMargin: 12, actionMargin: 12,
minActionMargin: 4, minActionMargin: 4,
agentLineHighlightRadius: 4, agentLineActivationRadius: 4,
agentCap: { agentCap: {
box: { box: {
@ -5288,6 +5288,44 @@
return components; 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 = { const OUTLINE_ATTRS = {
'class': 'outline', 'class': 'outline',
'fill': 'transparent', 'fill': 'transparent',
@ -5652,44 +5690,6 @@
register('agent begin', new AgentCap(true)); register('agent begin', new AgentCap(true));
register('agent end', new AgentCap(false)); 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 = { const OUTLINE_ATTRS$1 = {
'class': 'outline', 'class': 'outline',
'fill': 'transparent', 'fill': 'transparent',
@ -9185,7 +9185,7 @@
agentMargin: 10, agentMargin: 10,
actionMargin: 10, actionMargin: 10,
minActionMargin: 3, minActionMargin: 3,
agentLineHighlightRadius: 4, agentLineActivationRadius: 4,
agentCap: { agentCap: {
box: { box: {

File diff suppressed because one or more lines are too long

View File

@ -539,7 +539,7 @@
agentMargin: 10, agentMargin: 10,
actionMargin: 10, actionMargin: 10,
minActionMargin: 3, minActionMargin: 3,
agentLineHighlightRadius: 4, agentLineActivationRadius: 4,
agentCap: { agentCap: {
box: { box: {
@ -945,7 +945,7 @@
agentMargin: 8, agentMargin: 8,
actionMargin: 5, actionMargin: 5,
minActionMargin: 5, minActionMargin: 5,
agentLineHighlightRadius: 4, agentLineActivationRadius: 4,
agentCap: { agentCap: {
box: { box: {
@ -1599,14 +1599,14 @@
blocked = false, blocked = false,
covered = false, covered = false,
group = null, group = null,
highlighted = false, activated = false,
locked = false, locked = false,
visible = false, visible = false,
} = {}) { } = {}) {
this.blocked = blocked; this.blocked = blocked;
this.covered = covered; this.covered = covered;
this.group = group; this.group = group;
this.highlighted = highlighted; this.activated = activated;
this.locked = locked; this.locked = locked;
this.visible = visible; this.visible = visible;
} }
@ -1659,20 +1659,20 @@
const SPECIAL_AGENT_IDS = ['[', ']']; const SPECIAL_AGENT_IDS = ['[', ']'];
const MERGABLE = { const MERGABLE = {
'agent activation': {
check: ['activated'],
merge: ['agentIDs'],
siblings: new Set(['agent begin', 'agent end']),
},
'agent begin': { 'agent begin': {
check: ['mode'], check: ['mode'],
merge: ['agentIDs'], merge: ['agentIDs'],
siblings: new Set(['agent highlight']), siblings: new Set(['agent activation']),
}, },
'agent end': { 'agent end': {
check: ['mode'], check: ['mode'],
merge: ['agentIDs'], merge: ['agentIDs'],
siblings: new Set(['agent highlight']), siblings: new Set(['agent activation']),
},
'agent highlight': {
check: ['highlighted'],
merge: ['agentIDs'],
siblings: new Set(['agent begin', 'agent end']),
}, },
}; };
@ -1857,7 +1857,7 @@
const PARALLEL_STAGES = [ const PARALLEL_STAGES = [
'agent begin', 'agent begin',
'agent end', 'agent end',
'agent highlight', 'agent activation',
'block begin', 'block begin',
'block end', 'block end',
'connect', 'connect',
@ -2162,29 +2162,29 @@
}; };
} }
setGAgentHighlight(gAgents, highlighted, checked = false) { setGAgentActivation(gAgents, activated, checked = false) {
const filteredGAgents = gAgents.filter((gAgent) => { const filteredGAgents = gAgents.filter((gAgent) => {
const state = this.getGAgentState(gAgent); const state = this.getGAgentState(gAgent);
if(state.locked || state.blocked) { if(state.locked || state.blocked) {
if(checked) { if(checked) {
throw new Error('Cannot highlight agent: ' + gAgent.id); throw new Error('Cannot activate agent: ' + gAgent.id);
} else { } else {
return false; return false;
} }
} }
return state.visible && (state.highlighted !== highlighted); return state.visible && (state.activated !== activated);
}); });
if(filteredGAgents.length === 0) { if(filteredGAgents.length === 0) {
return null; return null;
} }
filteredGAgents.forEach((gAgent) => { filteredGAgents.forEach((gAgent) => {
this.updateGAgentState(gAgent, {highlighted}); this.updateGAgentState(gAgent, {activated});
}); });
return { return {
activated,
agentIDs: filteredGAgents.map((gAgent) => gAgent.id), agentIDs: filteredGAgents.map((gAgent) => gAgent.id),
highlighted, type: 'agent activation',
type: 'agent highlight',
}; };
} }
@ -2511,7 +2511,7 @@
); );
mergeSets(stopGAgents, endGAgents); mergeSets(stopGAgents, endGAgents);
if(GAgent.hasIntersection(startGAgents, stopGAgents)) { 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); this.validateGAgents(beginGAgents);
@ -2601,9 +2601,9 @@
_makeConnectParallelStages(flags, connectStage) { _makeConnectParallelStages(flags, connectStage) {
return this.makeParallel([ return this.makeParallel([
this.setGAgentVis(flags.beginGAgents, true, 'box', true), this.setGAgentVis(flags.beginGAgents, true, 'box', true),
this.setGAgentHighlight(flags.startGAgents, true, true), this.setGAgentActivation(flags.startGAgents, true, true),
connectStage, connectStage,
this.setGAgentHighlight(flags.stopGAgents, false, true), this.setGAgentActivation(flags.stopGAgents, false, true),
this.setGAgentVis(flags.endGAgents, false, 'cross', true), this.setGAgentVis(flags.endGAgents, false, 'cross', true),
]); ]);
} }
@ -2793,7 +2793,7 @@
); );
this.validateGAgents(gAgents); this.validateGAgents(gAgents);
this.addStage(this.makeParallel([ this.addStage(this.makeParallel([
this.setGAgentHighlight(gAgents, false), this.setGAgentActivation(gAgents, false),
this.setGAgentVis(gAgents, false, mode, true), this.setGAgentVis(gAgents, false, mode, true),
...groupPAgents.map(this.endGroup), ...groupPAgents.map(this.endGroup),
]), {parallel}); ]), {parallel});
@ -2866,7 +2866,7 @@
const terminators = meta.terminators || 'none'; const terminators = meta.terminators || 'none';
this.addStage(this.makeParallel([ this.addStage(this.makeParallel([
this.setGAgentHighlight(this.gAgents, false), this.setGAgentActivation(this.gAgents, false),
this.setGAgentVis(this.gAgents, false, terminators), this.setGAgentVis(this.gAgents, false, terminators),
])); ]));
@ -2962,7 +2962,7 @@
agentMargin: 12, agentMargin: 12,
actionMargin: 12, actionMargin: 12,
minActionMargin: 4, minActionMargin: 4,
agentLineHighlightRadius: 4, agentLineActivationRadius: 4,
agentCap: { agentCap: {
box: { box: {
@ -5288,6 +5288,44 @@
return components; 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 = { const OUTLINE_ATTRS = {
'class': 'outline', 'class': 'outline',
'fill': 'transparent', 'fill': 'transparent',
@ -5652,44 +5690,6 @@
register('agent begin', new AgentCap(true)); register('agent begin', new AgentCap(true));
register('agent end', new AgentCap(false)); 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 = { const OUTLINE_ATTRS$1 = {
'class': 'outline', 'class': 'outline',
'fill': 'transparent', 'fill': 'transparent',
@ -9185,7 +9185,7 @@
agentMargin: 10, agentMargin: 10,
actionMargin: 10, actionMargin: 10,
minActionMargin: 3, minActionMargin: 3,
agentLineHighlightRadius: 4, agentLineActivationRadius: 4,
agentCap: { agentCap: {
box: { box: {

View File

@ -15,14 +15,14 @@ class AgentState {
blocked = false, blocked = false,
covered = false, covered = false,
group = null, group = null,
highlighted = false, activated = false,
locked = false, locked = false,
visible = false, visible = false,
} = {}) { } = {}) {
this.blocked = blocked; this.blocked = blocked;
this.covered = covered; this.covered = covered;
this.group = group; this.group = group;
this.highlighted = highlighted; this.activated = activated;
this.locked = locked; this.locked = locked;
this.visible = visible; this.visible = visible;
} }
@ -75,20 +75,20 @@ const NOTE_DEFAULT_G_AGENTS = {
const SPECIAL_AGENT_IDS = ['[', ']']; const SPECIAL_AGENT_IDS = ['[', ']'];
const MERGABLE = { const MERGABLE = {
'agent activation': {
check: ['activated'],
merge: ['agentIDs'],
siblings: new Set(['agent begin', 'agent end']),
},
'agent begin': { 'agent begin': {
check: ['mode'], check: ['mode'],
merge: ['agentIDs'], merge: ['agentIDs'],
siblings: new Set(['agent highlight']), siblings: new Set(['agent activation']),
}, },
'agent end': { 'agent end': {
check: ['mode'], check: ['mode'],
merge: ['agentIDs'], merge: ['agentIDs'],
siblings: new Set(['agent highlight']), siblings: new Set(['agent activation']),
},
'agent highlight': {
check: ['highlighted'],
merge: ['agentIDs'],
siblings: new Set(['agent begin', 'agent end']),
}, },
}; };
@ -273,7 +273,7 @@ function checkDelayedConflicts(allStages) {
const PARALLEL_STAGES = [ const PARALLEL_STAGES = [
'agent begin', 'agent begin',
'agent end', 'agent end',
'agent highlight', 'agent activation',
'block begin', 'block begin',
'block end', 'block end',
'connect', '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 filteredGAgents = gAgents.filter((gAgent) => {
const state = this.getGAgentState(gAgent); const state = this.getGAgentState(gAgent);
if(state.locked || state.blocked) { if(state.locked || state.blocked) {
if(checked) { if(checked) {
throw new Error('Cannot highlight agent: ' + gAgent.id); throw new Error('Cannot activate agent: ' + gAgent.id);
} else { } else {
return false; return false;
} }
} }
return state.visible && (state.highlighted !== highlighted); return state.visible && (state.activated !== activated);
}); });
if(filteredGAgents.length === 0) { if(filteredGAgents.length === 0) {
return null; return null;
} }
filteredGAgents.forEach((gAgent) => { filteredGAgents.forEach((gAgent) => {
this.updateGAgentState(gAgent, {highlighted}); this.updateGAgentState(gAgent, {activated});
}); });
return { return {
activated,
agentIDs: filteredGAgents.map((gAgent) => gAgent.id), agentIDs: filteredGAgents.map((gAgent) => gAgent.id),
highlighted, type: 'agent activation',
type: 'agent highlight',
}; };
} }
@ -927,7 +927,7 @@ export default class Generator {
); );
mergeSets(stopGAgents, endGAgents); mergeSets(stopGAgents, endGAgents);
if(GAgent.hasIntersection(startGAgents, stopGAgents)) { 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); this.validateGAgents(beginGAgents);
@ -1017,9 +1017,9 @@ export default class Generator {
_makeConnectParallelStages(flags, connectStage) { _makeConnectParallelStages(flags, connectStage) {
return this.makeParallel([ return this.makeParallel([
this.setGAgentVis(flags.beginGAgents, true, 'box', true), this.setGAgentVis(flags.beginGAgents, true, 'box', true),
this.setGAgentHighlight(flags.startGAgents, true, true), this.setGAgentActivation(flags.startGAgents, true, true),
connectStage, connectStage,
this.setGAgentHighlight(flags.stopGAgents, false, true), this.setGAgentActivation(flags.stopGAgents, false, true),
this.setGAgentVis(flags.endGAgents, false, 'cross', true), this.setGAgentVis(flags.endGAgents, false, 'cross', true),
]); ]);
} }
@ -1209,7 +1209,7 @@ export default class Generator {
); );
this.validateGAgents(gAgents); this.validateGAgents(gAgents);
this.addStage(this.makeParallel([ this.addStage(this.makeParallel([
this.setGAgentHighlight(gAgents, false), this.setGAgentActivation(gAgents, false),
this.setGAgentVis(gAgents, false, mode, true), this.setGAgentVis(gAgents, false, mode, true),
...groupPAgents.map(this.endGroup), ...groupPAgents.map(this.endGroup),
]), {parallel}); ]), {parallel});
@ -1282,7 +1282,7 @@ export default class Generator {
const terminators = meta.terminators || 'none'; const terminators = meta.terminators || 'none';
this.addStage(this.makeParallel([ this.addStage(this.makeParallel([
this.setGAgentHighlight(this.gAgents, false), this.setGAgentActivation(this.gAgents, false),
this.setGAgentVis(this.gAgents, false, terminators), this.setGAgentVis(this.gAgents, false, terminators),
])); ]));

View File

@ -227,6 +227,15 @@ describe('Sequence Generator', () => {
}; };
const GENERATED = { const GENERATED = {
activation: (agentIDs, activated, {
ln = any(),
} = {}) => ({
activated,
agentIDs,
ln,
type: 'agent activation',
}),
agent: (id, { agent: (id, {
anchorRight = any(), anchorRight = any(),
formattedLabel = any(), formattedLabel = any(),
@ -373,15 +382,6 @@ describe('Sequence Generator', () => {
type: 'divider', type: 'divider',
}), }),
highlight: (agentIDs, highlighted, {
ln = any(),
} = {}) => ({
agentIDs,
highlighted,
ln,
type: 'agent highlight',
}),
mark: (name, { mark: (name, {
ln = any(), 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([ const sequence = invoke([
PARSED.connect([ PARSED.connect([
{flags: ['start'], name: 'A'}, {flags: ['start'], name: 'A'},
@ -871,12 +871,12 @@ describe('Sequence Generator', () => {
expect(sequence.stages).toEqual([ expect(sequence.stages).toEqual([
any(), any(),
GENERATED.parallel([ GENERATED.parallel([
GENERATED.highlight(['A'], true), GENERATED.activation(['A'], true),
GENERATED.connectBegin(['A', 'A'], {label: 'woo!'}), GENERATED.connectBegin(['A', 'A'], {label: 'woo!'}),
]), ]),
GENERATED.parallel([ GENERATED.parallel([
GENERATED.connectEnd(), GENERATED.connectEnd(),
GENERATED.highlight(['A'], false), GENERATED.activation(['A'], false),
]), ]),
any(), any(),
]); ]);
@ -1185,7 +1185,7 @@ describe('Sequence Generator', () => {
]); ]);
}); });
it('adds parallel highlighting stages', () => { it('adds parallel activation stages', () => {
const sequence = invoke([ const sequence = invoke([
PARSED.connect(['A', {flags: ['start'], name: 'B'}]), PARSED.connect(['A', {flags: ['start'], name: 'B'}]),
PARSED.connect(['A', {flags: ['stop'], name: 'B'}]), PARSED.connect(['A', {flags: ['stop'], name: 'B'}]),
@ -1194,12 +1194,12 @@ describe('Sequence Generator', () => {
expect(sequence.stages).toEqual([ expect(sequence.stages).toEqual([
any(), any(),
GENERATED.parallel([ GENERATED.parallel([
GENERATED.highlight(['B'], true), GENERATED.activation(['B'], true),
GENERATED.connect(['A', 'B']), GENERATED.connect(['A', 'B']),
]), ]),
GENERATED.parallel([ GENERATED.parallel([
GENERATED.connect(['A', 'B']), GENERATED.connect(['A', 'B']),
GENERATED.highlight(['B'], false), GENERATED.activation(['B'], false),
]), ]),
any(), 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([ const sequence = invoke([
PARSED.connect(['A', {flags: ['start'], name: 'B'}]), PARSED.connect(['A', {flags: ['start'], name: 'B'}]),
PARSED.connect(['A', {flags: ['end'], name: 'B'}]), PARSED.connect(['A', {flags: ['end'], name: 'B'}]),
@ -1246,7 +1246,7 @@ describe('Sequence Generator', () => {
any(), any(),
GENERATED.parallel([ GENERATED.parallel([
GENERATED.connect(['A', 'B']), GENERATED.connect(['A', 'B']),
GENERATED.highlight(['B'], false), GENERATED.activation(['B'], false),
GENERATED.agentEnd(['B']), GENERATED.agentEnd(['B']),
]), ]),
GENERATED.agentEnd(['A']), GENERATED.agentEnd(['A']),
@ -1260,7 +1260,7 @@ describe('Sequence Generator', () => {
{flags: ['start', 'stop'], name: 'B'}, {flags: ['start', 'stop'], name: 'B'},
]), ]),
])).toThrow(new Error( ])).toThrow(new Error(
'Cannot set agent highlighting multiple times at line 1' 'Cannot set agent activation multiple times at line 1'
)); ));
expect(() => invoke([ 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([ const sequence = invoke([
PARSED.connect([ PARSED.connect([
'A', 'A',
@ -1285,13 +1285,13 @@ describe('Sequence Generator', () => {
any(), any(),
any(), any(),
GENERATED.parallel([ GENERATED.parallel([
GENERATED.highlight(['B'], false), GENERATED.activation(['B'], false),
GENERATED.agentEnd(['A', 'B']), GENERATED.agentEnd(['A', 'B']),
]), ]),
]); ]);
}); });
it('adds implicit highlight end with explicit terminator', () => { it('adds implicit deactivation with explicit terminator', () => {
const sequence = invoke([ const sequence = invoke([
PARSED.connect(['A', {flags: ['start'], name: 'B'}]), PARSED.connect(['A', {flags: ['start'], name: 'B'}]),
PARSED.agentEnd(['A', 'B']), PARSED.agentEnd(['A', 'B']),
@ -1301,13 +1301,13 @@ describe('Sequence Generator', () => {
any(), any(),
any(), any(),
GENERATED.parallel([ GENERATED.parallel([
GENERATED.highlight(['B'], false), GENERATED.activation(['B'], false),
GENERATED.agentEnd(['A', 'B']), GENERATED.agentEnd(['A', 'B']),
]), ]),
]); ]);
}); });
it('collapses adjacent end statements containing highlighting', () => { it('collapses adjacent end statements containing activation', () => {
const sequence = invoke([ const sequence = invoke([
PARSED.connect([ PARSED.connect([
{flags: ['start'], name: 'A'}, {flags: ['start'], name: 'A'},
@ -1321,7 +1321,7 @@ describe('Sequence Generator', () => {
any(), any(),
any(), any(),
GENERATED.parallel([ GENERATED.parallel([
GENERATED.highlight(['A', 'B'], false), GENERATED.activation(['A', 'B'], false),
GENERATED.agentEnd(['A', 'B']), GENERATED.agentEnd(['A', 'B']),
]), ]),
]); ]);

View File

@ -1,5 +1,5 @@
import './components/Activation.mjs';
import './components/AgentCap.mjs'; import './components/AgentCap.mjs';
import './components/AgentHighlight.mjs';
import './components/Block.mjs'; import './components/Block.mjs';
import './components/Connect.mjs'; import './components/Connect.mjs';
import './components/Divider.mjs'; import './components/Divider.mjs';

View File

@ -1,12 +1,12 @@
import BaseComponent, {register} from './BaseComponent.mjs'; import BaseComponent, {register} from './BaseComponent.mjs';
export default class AgentHighlight extends BaseComponent { export default class Activation extends BaseComponent {
radius(highlighted, env) { radius(activated, env) {
return highlighted ? env.theme.agentLineHighlightRadius : 0; return activated ? env.theme.agentLineActivationRadius : 0;
} }
separationPre({agentIDs, highlighted}, env) { separationPre({agentIDs, activated}, env) {
const r = this.radius(highlighted, env); const r = this.radius(activated, env);
agentIDs.forEach((id) => { agentIDs.forEach((id) => {
const agentInfo = env.agentInfos.get(id); const agentInfo = env.agentInfos.get(id);
agentInfo.currentRad = r; agentInfo.currentRad = r;
@ -14,16 +14,16 @@ export default class AgentHighlight extends BaseComponent {
}); });
} }
renderPre({agentIDs, highlighted}, env) { renderPre({agentIDs, activated}, env) {
const r = this.radius(highlighted, env); const r = this.radius(activated, env);
agentIDs.forEach((id) => { agentIDs.forEach((id) => {
const agentInfo = env.agentInfos.get(id); const agentInfo = env.agentInfos.get(id);
agentInfo.currentMaxRad = Math.max(agentInfo.currentMaxRad, r); agentInfo.currentMaxRad = Math.max(agentInfo.currentMaxRad, r);
}); });
} }
render({agentIDs, highlighted}, env) { render({agentIDs, activated}, env) {
const r = this.radius(highlighted, env); const r = this.radius(activated, env);
agentIDs.forEach((id) => { agentIDs.forEach((id) => {
env.drawAgentLine(id, env.primaryY); env.drawAgentLine(id, env.primaryY);
env.agentInfos.get(id).currentRad = r; 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());

View File

@ -1,18 +1,18 @@
import AgentHighlight from './AgentHighlight.mjs'; import Activation from './Activation.mjs';
import {getComponents} from './BaseComponent.mjs'; import {getComponents} from './BaseComponent.mjs';
describe('AgentHighlight', () => { describe('Activation', () => {
const highlight = new AgentHighlight(); const activation = new Activation();
const theme = { const theme = {
agentLineHighlightRadius: 2, agentLineActivationRadius: 2,
}; };
it('registers itself with the component store', () => { it('registers itself with the component store', () => {
const components = getComponents(); const components = getComponents();
expect(components.get('agent highlight')).toEqual( expect(components.get('agent activation')).toEqual(
jasmine.any(AgentHighlight) jasmine.any(Activation)
); );
}); });
@ -24,7 +24,7 @@ describe('AgentHighlight', () => {
agentInfos, agentInfos,
theme, theme,
}; };
highlight.separationPre({agentIDs: ['foo'], highlighted: true}, env); activation.separationPre({activated: true, agentIDs: ['foo']}, env);
expect(agentInfo.currentRad).toEqual(2); expect(agentInfo.currentRad).toEqual(2);
expect(agentInfo.currentMaxRad).toEqual(2); expect(agentInfo.currentMaxRad).toEqual(2);
@ -38,13 +38,13 @@ describe('AgentHighlight', () => {
agentInfos, agentInfos,
theme, theme,
}; };
highlight.separationPre({agentIDs: ['foo'], highlighted: true}, env); activation.separationPre({activated: true, agentIDs: ['foo']}, env);
expect(agentInfo.currentRad).toEqual(2); expect(agentInfo.currentRad).toEqual(2);
expect(agentInfo.currentMaxRad).toEqual(3); 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 agentInfo = {currentMaxRad: 1, currentRad: 0};
const agentInfos = new Map(); const agentInfos = new Map();
agentInfos.set('foo', agentInfo); agentInfos.set('foo', agentInfo);
@ -52,7 +52,7 @@ describe('AgentHighlight', () => {
agentInfos, agentInfos,
theme, theme,
}; };
highlight.separationPre({agentIDs: ['foo'], highlighted: false}, env); activation.separationPre({activated: false, agentIDs: ['foo']}, env);
expect(agentInfo.currentRad).toEqual(0); expect(agentInfo.currentRad).toEqual(0);
expect(agentInfo.currentMaxRad).toEqual(1); expect(agentInfo.currentMaxRad).toEqual(1);

View File

@ -76,7 +76,7 @@ export default class BasicTheme extends BaseTheme {
agentMargin: 10, agentMargin: 10,
actionMargin: 10, actionMargin: 10,
minActionMargin: 3, minActionMargin: 3,
agentLineHighlightRadius: 4, agentLineActivationRadius: 4,
agentCap: { agentCap: {
box: { box: {

View File

@ -76,7 +76,7 @@ export default class ChunkyTheme extends BaseTheme {
agentMargin: 8, agentMargin: 8,
actionMargin: 5, actionMargin: 5,
minActionMargin: 5, minActionMargin: 5,
agentLineHighlightRadius: 4, agentLineActivationRadius: 4,
agentCap: { agentCap: {
box: { box: {

View File

@ -76,7 +76,7 @@ export default class MonospaceTheme extends BaseTheme {
agentMargin: 12, agentMargin: 12,
actionMargin: 12, actionMargin: 12,
minActionMargin: 4, minActionMargin: 4,
agentLineHighlightRadius: 4, agentLineActivationRadius: 4,
agentCap: { agentCap: {
box: { box: {

View File

@ -126,7 +126,7 @@ export default class SketchTheme extends BaseTheme {
agentMargin: 10, agentMargin: 10,
actionMargin: 10, actionMargin: 10,
minActionMargin: 3, minActionMargin: 3,
agentLineHighlightRadius: 4, agentLineActivationRadius: 4,
agentCap: { agentCap: {
box: { box: {