aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/frontend
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2023-08-30 02:31:49 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2023-08-30 02:36:21 +0200
commit1d9057f2d9cb39d8f3ffd3403aee3f0588fb1f27 (patch)
tree4dc6cdf86b823ad301658e24c962e13ee9e4ee2c /subprojects/frontend
parentfeat(frontend): projection dialog (diff)
downloadrefinery-1d9057f2d9cb39d8f3ffd3403aee3f0588fb1f27.tar.gz
refinery-1d9057f2d9cb39d8f3ffd3403aee3f0588fb1f27.tar.zst
refinery-1d9057f2d9cb39d8f3ffd3403aee3f0588fb1f27.zip
feat(frontend): hide isolated nodes
Diffstat (limited to 'subprojects/frontend')
-rw-r--r--subprojects/frontend/src/graph/dotSource.ts43
-rw-r--r--subprojects/frontend/src/graph/postProcessSVG.ts4
2 files changed, 32 insertions, 15 deletions
diff --git a/subprojects/frontend/src/graph/dotSource.ts b/subprojects/frontend/src/graph/dotSource.ts
index 701453f4..963a9663 100644
--- a/subprojects/frontend/src/graph/dotSource.ts
+++ b/subprojects/frontend/src/graph/dotSource.ts
@@ -40,6 +40,7 @@ function relationName(graph: GraphStore, metadata: RelationMetadata): string {
40} 40}
41 41
42interface NodeData { 42interface NodeData {
43 isolated: boolean;
43 exists: string; 44 exists: string;
44 equalsSelf: string; 45 equalsSelf: string;
45 unaryPredicates: Map<RelationMetadata, string>; 46 unaryPredicates: Map<RelationMetadata, string>;
@@ -51,27 +52,35 @@ function computeNodeData(graph: GraphStore): NodeData[] {
51 } = graph; 52 } = graph;
52 53
53 const nodeData = Array.from(Array(nodes.length)).map(() => ({ 54 const nodeData = Array.from(Array(nodes.length)).map(() => ({
55 isolated: true,
54 exists: 'FALSE', 56 exists: 'FALSE',
55 equalsSelf: 'FALSE', 57 equalsSelf: 'FALSE',
56 unaryPredicates: new Map(), 58 unaryPredicates: new Map(),
57 })); 59 }));
58 60
59 relations.forEach((relation) => { 61 relations.forEach((relation) => {
60 if (relation.arity !== 1) {
61 return;
62 }
63 const visibility = graph.getVisibility(relation.name); 62 const visibility = graph.getVisibility(relation.name);
64 if (visibility === 'none') { 63 if (visibility === 'none') {
65 return; 64 return;
66 } 65 }
66 const { arity } = relation;
67 const interpretation = partialInterpretation[relation.name] ?? []; 67 const interpretation = partialInterpretation[relation.name] ?? [];
68 interpretation.forEach(([index, value]) => { 68 interpretation.forEach((tuple) => {
69 if ( 69 const value = tuple[arity];
70 typeof index === 'number' && 70 if (visibility !== 'all' && value === 'UNKNOWN') {
71 typeof value === 'string' && 71 return;
72 (visibility === 'all' || value !== 'UNKNOWN') 72 }
73 ) { 73 for (let i = 0; i < arity; i += 1) {
74 nodeData[index]?.unaryPredicates?.set(relation, value); 74 const index = tuple[i];
75 if (typeof index === 'number') {
76 const data = nodeData[index];
77 if (data !== undefined) {
78 data.isolated = false;
79 if (arity === 1) {
80 data.unaryPredicates.set(relation, value);
81 }
82 }
83 }
75 } 84 }
76 }); 85 });
77 }); 86 });
@@ -109,12 +118,18 @@ function createNodes(graph: GraphStore, lines: string[]): void {
109 118
110 nodes.forEach((node, i) => { 119 nodes.forEach((node, i) => {
111 const data = nodeData[i]; 120 const data = nodeData[i];
112 if (data === undefined) { 121 if (data === undefined || data.isolated) {
113 return; 122 return;
114 } 123 }
115 const classes = [ 124 const classList = [
116 `node-${node.kind} node-exists-${data.exists} node-equalsSelf-${data.equalsSelf}`, 125 `node-${node.kind}`,
117 ].join(' '); 126 `node-exists-${data.exists}`,
127 `node-equalsSelf-${data.equalsSelf}`,
128 ];
129 if (data.unaryPredicates.size === 0) {
130 classList.push('node-empty');
131 }
132 const classes = classList.join(' ');
118 const name = nodeName(graph, node); 133 const name = nodeName(graph, node);
119 const border = node.kind === 'INDIVIDUAL' ? 2 : 1; 134 const border = node.kind === 'INDIVIDUAL' ? 2 : 1;
120 lines.push(`n${i} [id="${node.name}", class="${classes}", label=< 135 lines.push(`n${i} [id="${node.name}", class="${classes}", label=<
diff --git a/subprojects/frontend/src/graph/postProcessSVG.ts b/subprojects/frontend/src/graph/postProcessSVG.ts
index 13e4eb29..a580f5c6 100644
--- a/subprojects/frontend/src/graph/postProcessSVG.ts
+++ b/subprojects/frontend/src/graph/postProcessSVG.ts
@@ -62,7 +62,9 @@ function clipCompartmentBackground(node: SVGGElement) {
62 modifyAttribute(compartment, 'y', -5); 62 modifyAttribute(compartment, 'y', -5);
63 modifyAttribute(compartment, 'x', -5); 63 modifyAttribute(compartment, 'x', -5);
64 modifyAttribute(compartment, 'width', 10); 64 modifyAttribute(compartment, 'width', 10);
65 modifyAttribute(compartment, 'height', 5); 65 const isEmpty = node.classList.contains('node-empty');
66 // Make sure that empty nodes are fully filled.
67 modifyAttribute(compartment, 'height', isEmpty ? 10 : 5);
66 if (node.classList.contains('node-equalsSelf-UNKNOWN')) { 68 if (node.classList.contains('node-equalsSelf-UNKNOWN')) {
67 addShadow(node, container, 6); 69 addShadow(node, container, 6);
68 } 70 }